Alert Dialog
Blocking confirmation with action and cancel.
Installation
Usage
Examples
Default size
Roomier dialog for longer explanations. Uses the default size.
Small size
Compact dialog for short confirmations.
API reference
AlertDialog
| Prop | Type | Default |
|---|---|---|
openControlled open state. Use with onOpenChange. | boolean | - |
defaultOpenInitially open when uncontrolled. | boolean | false |
onOpenChangeCalled when the dialog opens or closes. | (open: boolean) => void | - |
onOpenChangeCompleteCalled after open or close animations finish. | (open: boolean) => void | - |
AlertDialogContent
| Prop | Type | Default |
|---|---|---|
sizeWidth preset. Both cap at max-w-xs on small screens; default grows to max-w-sm on sm screens and up. | "default" | "sm" | "default" |
renderPolymorphic render prop. Use to render a custom element instead of the default popup. | ReactElement | ((props) => ReactNode) | - |
classNameAdditional classes merged with the default content styles. | string | - |
AlertDialogTrigger
| Prop | Type | Default |
|---|---|---|
renderRender a custom trigger element, e.g. render={<Button variant="destructive">Delete</Button>}. | ReactElement | ((props) => ReactNode) | - |
disabledDisable the trigger. | boolean | false |
AlertDialogAction
| Prop | Type | Default |
|---|---|---|
variantConfirm button style. | "default" | "secondary" | "outline" | "ghost" | "destructive" | "link" | "destructive" |
sizeConfirm button size. | "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | "default" |
childrenButton label. | ReactNode | - |
classNameAdditional classes merged with the button styles. | string | - |
AlertDialogCancel
| Prop | Type | Default |
|---|---|---|
variantCancel button style. | "default" | "secondary" | "outline" | "ghost" | "destructive" | "link" | "outline" |
sizeCancel button size. | "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | "default" |
childrenButton label. | ReactNode | - |
classNameAdditional classes merged with the button styles. | string | - |