A modal dialog that interrupts the user with important content and expects a response.
A composable alert dialog built on Base UI's AlertDialog primitive. Use it for destructive confirmations or important decisions that require the user to acknowledge before continuing.
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog"
import { Button } from "@/components/ui/button"
export default function AlertDialogDemo() {
return (
<AlertDialog>
<AlertDialogTrigger render={<Button variant="outline" />}>
Delete account
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
<AlertDialogDescription>
This action cannot be undone. This will permanently delete your
account and remove your data from our servers.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction variant="destructive">Delete</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
)
}
import {
AlertDialog,
AlertDialogTrigger,
AlertDialogContent,
AlertDialogHeader,
AlertDialogFooter,
AlertDialogTitle,
AlertDialogDescription,
AlertDialogAction,
AlertDialogCancel,
AlertDialogMedia,
AlertDialogOverlay,
AlertDialogPortal,
} from "@/components/ui/alert-dialog"<AlertDialog>
<AlertDialogTrigger>
<Button>Open</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Are you sure?</AlertDialogTitle>
<AlertDialogDescription>This action cannot be undone.</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction>Continue</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog><AlertDialog>
<AlertDialogTrigger>
<Button variant="destructive">Delete account</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Delete account?</AlertDialogTitle>
<AlertDialogDescription>
This will permanently delete your account and all associated data.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction variant="destructive">Delete</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>Use size="sm" on AlertDialogContent for a compact, centered layout with a two-column footer.
<AlertDialog>
<AlertDialogTrigger>
<Button>Confirm</Button>
</AlertDialogTrigger>
<AlertDialogContent size="sm">
<AlertDialogHeader>
<AlertDialogTitle>Confirm action</AlertDialogTitle>
<AlertDialogDescription>Are you sure you want to proceed?</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>No</AlertDialogCancel>
<AlertDialogAction>Yes</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>Use AlertDialogMedia inside the header to display an icon or illustration alongside the title and description.
<AlertDialog>
<AlertDialogTrigger>
<Button>Open</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogMedia>
<TrashIcon />
</AlertDialogMedia>
<AlertDialogTitle>Delete item</AlertDialogTitle>
<AlertDialogDescription>
This item will be permanently removed.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction variant="destructive">Delete</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>The root component. Manages open/closed state.
| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | — | Controlled open state. |
onOpenChange | (open: boolean) => void | — | Callback when the open state changes. |
children | ReactNode | — |
The element that opens the dialog.
| Prop | Type | Default |
|---|---|---|
className | string | — |
children | ReactNode | — |
The dialog popup panel. Automatically renders inside a portal with a backdrop overlay.
| Prop | Type | Default | Description |
|---|---|---|---|
size | "default" | "sm" | "default" | Controls the max-width and layout. "sm" produces a compact centered dialog. |
className | string | — | |
children | ReactNode | — |
The backdrop behind the dialog. Renders a blurred, semi-transparent overlay.
| Prop | Type | Default |
|---|---|---|
className | string | — |
Renders children into a React portal.
| Prop | Type | Default |
|---|---|---|
children | ReactNode | — |
Layout container for the title, description, and optional media.
| Prop | Type | Default |
|---|---|---|
className | string | — |
children | ReactNode | — |
Layout container for the action and cancel buttons.
| Prop | Type | Default |
|---|---|---|
className | string | — |
children | ReactNode | — |
An icon or illustration area inside the header. Renders as a 64px square with a muted background.
| Prop | Type | Default |
|---|---|---|
className | string | — |
children | ReactNode | — |
The dialog title.
| Prop | Type | Default |
|---|---|---|
className | string | — |
children | ReactNode | — |
The dialog description text.
| Prop | Type | Default |
|---|---|---|
className | string | — |
children | ReactNode | — |
A styled Button for the primary action (e.g. "Delete", "Continue"). Accepts all Button props.
| Prop | Type | Default |
|---|---|---|
variant | ButtonVariant | "default" |
size | ButtonSize | "default" |
className | string | — |
children | ReactNode | — |
A close button for cancelling the dialog. Renders as an outline Button by default.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | ButtonVariant | "outline" | The button variant. |
size | ButtonSize | "default" | The button size. |
className | string | — | |
children | ReactNode | — |