Alert Dialog
An interruptive confirmation dialog with a scale entrance, backdrop blur, outside-click shake feedback, focus trap, and Escape dismissal.
Customize
Installation
npx shadcn@latest add @kinetic/alert-dialogUsage
Compose the dialog from its parts. The trigger opens it; AlertDialogAction and AlertDialogCancel close it.
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/kinetic/ui/alert-dialog";
export function DeleteProject() {
return (
<AlertDialog>
<AlertDialogTrigger>Delete project</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Delete this project?</AlertDialogTitle>
<AlertDialogDescription>This action cannot be undone.</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction variant="destructive">Delete</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}Controlled state
Pass open and onOpenChange to control the dialog, or defaultOpen for an uncontrolled initial state.
<AlertDialog open={open} onOpenChange={setOpen}>
...
</AlertDialog>Size and media icon
Set size on AlertDialogContent to default or sm. The small size uses a narrower panel and a two-column footer. Add AlertDialogMedia inside AlertDialogHeader to display an icon badge that automatically aligns beside the title on default size.
import { TrashIcon } from "@heroicons/react/24/outline";
import {
AlertDialogContent,
AlertDialogDescription,
AlertDialogHeader,
AlertDialogMedia,
AlertDialogTitle,
} from "@/components/kinetic/ui/alert-dialog";
<AlertDialogContent size="default">
<AlertDialogHeader>
<AlertDialogMedia>
<TrashIcon />
</AlertDialogMedia>
<AlertDialogTitle>Delete deployment?</AlertDialogTitle>
<AlertDialogDescription>This action cannot be undone.</AlertDialogDescription>
</AlertDialogHeader>
</AlertDialogContent>Portal and overlay
AlertDialogContent automatically renders inside a portal with a blur backdrop. For custom portal targets or backdrop styling, wrap AlertDialogContent explicitly in AlertDialogPortal and AlertDialogOverlay, or pass asChild to AlertDialogTrigger.
import {
AlertDialog,
AlertDialogContent,
AlertDialogOverlay,
AlertDialogPortal,
AlertDialogTrigger,
} from "@/components/kinetic/ui/alert-dialog";
import { Button } from "@/components/kinetic/ui/button";
<AlertDialog>
<AlertDialogTrigger asChild>
<Button variant="destructive">Revoke key</Button>
</AlertDialogTrigger>
<AlertDialogPortal>
<AlertDialogOverlay className="bg-black/60" />
<AlertDialogContent>...</AlertDialogContent>
</AlertDialogPortal>
</AlertDialog>Action buttons
AlertDialogAction and AlertDialogCancel accept variant (default, destructive, outline, secondary, ghost) and size (default, sm, lg).
<AlertDialogCancel variant="outline">Keep</AlertDialogCancel>
<AlertDialogAction variant="destructive" size="lg">Remove</AlertDialogAction>Outside-click feedback
An alert dialog is not dismissed by clicking outside. By default the panel shakes to signal this unless reduced motion is enabled. Set shakeOnOutsideClick={false} on AlertDialog or AlertDialogContent to disable it.
<AlertDialog shakeOnOutsideClick={false}>...</AlertDialog>Speed and blur
speed scales the animation, blurPx sets the entrance blur, and backdropBlurPx sets the backdrop blur.
<AlertDialog speed={1.5} blurPx={6} backdropBlurPx={8}>...</AlertDialog>Motion preferences
With reduced motion enabled, the entrance avoids spatial movement and uses a short fade. Animation timing follows the current Kinetic tempo. Focus is trapped while open and starts on AlertDialogCancel when present; Escape closes the dialog and focus returns to the trigger.
API Reference
AlertDialog
Zero-dependency alert dialog root managing open state, speed, blur, and shake feedback.
| Prop | Type | Default | Description |
|---|---|---|---|
open / defaultOpen / onOpenChange | boolean / (open: boolean) => void | - | Controlled or uncontrolled open state. |
speed / blurPx / backdropBlurPx | number | 1 / 6 / 6 | Animation speed multiplier (0.25 to 4), entrance motion blur (px), and backdrop blur radius (0 to 20). |
shakeOnOutsideClick | boolean | true | Plays a subtle horizontal shake when clicking the backdrop instead of dismissing. |
AlertDialogPortal / AlertDialogOverlay / AlertDialogTrigger
Optional explicit portal target, animated blur backdrop overlay, and trigger with asChild slot support.
| Prop | Type | Default | Description |
|---|---|---|---|
container (AlertDialogPortal) | Element | null | document.body | Optional DOM target for portaled alert dialog nodes. |
backdropBlurPx (AlertDialogOverlay) | number | 6 | Optional backdrop blur override on the overlay layer. |
asChild (AlertDialogTrigger) | boolean | false | Merges trigger props onto a child button element. |
AlertDialogContent
Portaled alert surface with focus trap, Escape dismissal, and Web Animations API transitions.
| Prop | Type | Default | Description |
|---|---|---|---|
size | "default" | "sm" | "default" | Switches between standard width and compact confirmation layout. |
speed / blurPx / backdropBlurPx / shakeOnOutsideClick | number / number / number / boolean | - | Optional per-content overrides for root motion settings. |
AlertDialogMedia / AlertDialogHeader / AlertDialogTitle / AlertDialogDescription / AlertDialogFooter
Optional icon badge slot and structured header, title, description, and footer layout primitives.
| Prop | Type | Default | Description |
|---|---|---|---|
...props | React.ComponentProps<...> | - | Forwards standard HTML div, heading, and paragraph attributes. |
AlertDialogAction / AlertDialogCancel
Built-in styled confirmation and cancellation buttons that close the dialog on click.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "default" | "destructive" | "outline" | "secondary" | "ghost" | "default" / "outline" | Visual emphasis variant for action or cancel buttons. |
size | "default" | "sm" | "lg" | "default" | Button height and horizontal padding preset. |