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 the direction once with DirectionProvider (or <html dir="rtl">) and the alert dialog follows. It extends Dialog, so the portaled content gets the resolved dir and the footer actions mirror without any extra props.
<DirectionProviderdir="rtl"> <AlertDialog> <AlertDialogTrigger>حذف الحساب</AlertDialogTrigger> <AlertDialogContent> <AlertDialogHeader> <AlertDialogTitle>هل أنت متأكد؟</AlertDialogTitle> <AlertDialogDescription>لا يمكن التراجع عن هذا الإجراء.</AlertDialogDescription> </AlertDialogHeader> <AlertDialogFooter> <AlertDialogCancel>إلغاء</AlertDialogCancel> <AlertDialogAction>متابعة</AlertDialogAction> </AlertDialogFooter> </AlertDialogContent> </AlertDialog></DirectionProvider>
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'
-
Optional override. Resolved by primitives useDirection (dir prop -> DirectionProvider -> <html dir>). 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. Content uses a scaleIn entrance (fade, scale, and blur) with a spring transition (stiffness 400, damping 30) for a snappier feel that conveys urgency; the overlay fades in independently. 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)