Alert
A callout with five semantic tones, a blur reveal on mount, a short shake for destructive alerts and a spring height collapse when dismissed.
Customize
Installation
npx shadcn@latest add @kinetic/alertUsage
Put an icon, an AlertTitle and an AlertDescription inside Alert.
import { CheckCircleIcon } from "@heroicons/react/24/outline";
import { Alert, AlertDescription, AlertTitle } from "@/components/kinetic/ui/alert";
export function Synced() {
return (
<Alert variant="success">
<CheckCircleIcon />
<AlertTitle>Changes saved</AlertTitle>
<AlertDescription>Your profile is up to date.</AlertDescription>
</Alert>
);
}Variants
Use variant with default, destructive, success, warning or info. Every alert renders with role="alert".
<Alert variant="warning">...</Alert>
<Alert variant="destructive">...</Alert>Dismissible
Set dismissible to add a close button. The alert collapses its height with a spring and then unmounts. dismissLabel sets the button's accessible name.
<Alert dismissible dismissLabel="Hide notice">...</Alert>Controlled
Pass open and onOpenChange to drive visibility yourself, or defaultOpen to start hidden. Opening again plays the reveal.
const [open, setOpen] = useState(true);
<Alert open={open} onOpenChange={setOpen} dismissible>...</Alert>Action
Add an AlertAction row for buttons that line up with the text column.
<Alert variant="info">
<AlertTitle>Update available</AlertTitle>
<AlertDescription>Version 2.4 is ready to install.</AlertDescription>
<AlertAction>
<Button size="sm">Install</Button>
</AlertAction>
</Alert>Motion preferences
animateOnMount plays the blur reveal on first render and shakeOnDestructive adds the horizontal shake. Tune them with blurPx and speed. Reduced motion shows and hides the alert without movement.
API Reference
Alert
Zero-dependency callout alert with five semantic variants, WAAPI blur-to-sharp entrance, optional destructive shake, and Euler spring height collapse.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "default" | "destructive" | "success" | "warning" | "info" | "default" | Visual and semantic tone for the alert callout. |
open / defaultOpen / onOpenChange | boolean / boolean / (open: boolean) => void | true | Controlled or uncontrolled visibility driving spring height collapse. |
dismissible / dismissLabel | boolean / string | false / "Dismiss alert" | Renders an accessible 24x24px close button in the top-right corner. |
animateOnMount / shakeOnDestructive / blurPx / speed | boolean / boolean / number / number | true / true / 8 / 0.4 | Configures blur reveal on mount, horizontal destructive shake, blur radius, and speed. |
AlertTitle / AlertDescription / AlertAction
Clamped heading, rich description track, and inline action row aligned with the content column.
| Prop | Type | Default | Description |
|---|---|---|---|
...props | React.ComponentProps<"div"> | - | Standard div attributes. |