AlertDialog
Modal confirmation dialog that interrupts the user for a decision that can't
be dismissed by clicking outside — use for destructive or irreversible
actions. Open state is controlled (open) or uncontrolled (defaultOpen);
compose with AlertDialogTrigger and AlertDialogContent.
Usage
@desk/ui/components/alert-dialog
<AlertDialog>
<AlertDialogTrigger asChild>
<Button emphasis="outline" icon={Trash2} tone="danger">
Remove material
</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Remove this material?</AlertDialogTitle>
<AlertDialogDescription>
Terrazzo Bianco will be taken off your Coastal Kitchen board. This
can't be undone.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction tone="danger">Remove</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>Best practices
Use
AlertDialogonly for a confirm / warn / destructive decision (Cancel + Action); a general modal form or details view is aDialog.Route every destructive confirmation here, never a plain
Dialog— unlikeDialogit won't dismiss on outside-click / Esc, so the choice stays deliberate.Give the destructive
AlertDialogActiontone="danger"and keep the safe escape asAlertDialogCancel.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| tone | ButtonTone | Button tone; pass |
Also exports
- component
AlertDialog - component
AlertDialogCancel - component
AlertDialogContent - component
AlertDialogDescription - component
AlertDialogFooter - component
AlertDialogHeader - component
AlertDialogOverlay - component
AlertDialogPortal - component
AlertDialogTitle - component
AlertDialogTrigger
Composition
Builds on