A modal dialog temporarily interrupts the user's workflow with important content, requiring immediate attention and a response before allowing further interaction.
Philosophy
Alert dialogs are the nuclear option of UI interruption. Unlike regular dialogs, they can't be dismissed by clicking outside or pressing Escape - the user must explicitly choose an action. Reserve them for destructive operations where an accidental dismissal could mean data loss.
<AlertDialog> <AlertDialogTrigger>Open</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>Continue</AlertDialogAction> </AlertDialogFooter> </AlertDialogContent></AlertDialog>
Examples
Active Trigger on Open
Style the trigger to appear active while the alert dialog is open using data-[state=open]:
Component Composition
RTL Support
Set dir="rtl" on AlertDialog for a local override, or set DirectionProvider once at app/root level for global direction. AlertDialog extends Dialog, so direction is inherited by all child parts.
<AlertDialogdir="rtl"> <AlertDialogTrigger>Open</AlertDialogTrigger> <AlertDialogContent> <AlertDialogHeader> <AlertDialogTitle>هل انت متاكد؟</AlertDialogTitle> <AlertDialogDescription> هذا الاجراء لا يمكن التراجع عنه.
</AlertDialogDescription> </AlertDialogHeader> <AlertDialogFooter> <AlertDialogCancel>الغاء</AlertDialogCancel> <AlertDialogAction>متابعة</AlertDialogAction> </AlertDialogFooter> </AlertDialogContent></AlertDialog>
Motion
Alpha: Motion Compositions
Motion components work standalone, but some compositions may behave unexpectedly — this is still under active development. If you find a broken composition, please file an issue.
Use MotionAlertDialog and MotionAlertDialogContent for smooth enter/exit animations powered by motion. Uses a stiffer spring to convey urgency compared to the regular dialog.
Requires the motion package. Use MotionAlertDialog instead of AlertDialog and MotionAlertDialogContent instead of AlertDialogContent. All other sub-components (AlertDialogTrigger, AlertDialogAction, etc.) stay the same.
API Reference
AlertDialog
Prop
Type
Default
Description
defaultOpen
boolean
-
Determines if the dialog should be open by default
open
boolean
-
Controls the visibility of the dialog
onOpenChange
(open: boolean) => void
-
Callback fired when the dialog opens or closes
dir
'ltr' | 'rtl'
-
Text direction. Resolved by primitives useDirection (dir prop -> DirectionProvider -> 'ltr'). Inherited from the Dialog primitive.
Additional props inherited from AlertDialogPrimitive.Content
MotionAlertDialog
Same props as AlertDialog. Wraps with useMotionRoot for exit animation support. Requires the motion package.
MotionAlertDialogContent
Prop
Type
Default
Description
open
boolean
-
Required. Controlled open state for AnimatePresence enter/exit
className
string
-
Additional class names to apply
children
React.ReactNode
-
Content displayed inside the dialog
Requires motion package installed. Uses a spring transition (stiffness 400, damping 30) for a snappier feel that conveys urgency. Automatically respects prefers-reduced-motion.
AlertDialogHeader
Prop
Type
Default
Description
className
string
--
Additional class names to apply
children
React.ReactNode
--
Header content (typically Title and Description)
...props
React.HTMLAttributes<HTMLDivElement>
-
Additional props to spread to the header container
AlertDialogFooter
Prop
Type
Default
Description
className
string
--
Additional class names to apply
children
React.ReactNode
--
Footer content (typically Action and Cancel buttons)