Alert dialog
Asks to confirm something that cannot be undone. It does not close on an outside click; focus starts on Cancel. For anything else, use Dialog.
Installation
Or with the shadcn CLI, from the registry:
It installs Button too.
Usage
Sizes
size on AlertDialogContent: sm, default or lg, the width from the sm breakpoint. There is no full: a question
that needs an answer before anything else stays small. The action takes a Button's variant, tone and size.
Villages
The dialog's surface and backdrop; Action and Cancel are buttons in the village's look.
Accessibility
- The popup is an
alertdialog, named by its title and described by its description. - Focus starts on Cancel, the safe choice; Esc cancels; a click on the backdrop does nothing.
API reference
The parts of Base UI's Alert Dialog, styled:
| Part | Notes |
|---|---|
AlertDialog | open, defaultOpen, onOpenChange |
AlertDialogTrigger | render to use a Button |
AlertDialogContent | portal, backdrop and popup; size ("sm" | "default" | "lg") |
AlertDialogHeader, AlertDialogFooter | layout |
AlertDialogTitle, AlertDialogDescription | name and describe it |
AlertDialogAction | closes it; variant, tone and size of a Button |
AlertDialogCancel | closes it; variant (default "outline"), focused first |