Alert Dialog
stableA modal dialog that interrupts the user and expects a response.
Basic usage
Examples
With async action
Disable the action button while async work is in progress.
Destructive confirmation
AlertDialog blocks outside interaction and starts focus on the safest action.
Features
- Focus starts on Cancel.
- Outside interaction is blocked.
Installation
pnpm dlx structyl add alert-dialogAPI Reference
AlertDialog.Root
A confirmation dialog requiring an explicit choice.
| Prop | Type | Default |
|---|---|---|
| open | booleanControlled open state. | — |
| defaultOpen | booleanInitial open state. | — |
| onOpenChange | (open: boolean) => voidCalled when open state changes. | — |
AlertDialog.Trigger
Opens the alert dialog.
| Prop | Type | Default |
|---|---|---|
| asChild | booleanMerge props onto the immediate child instead of rendering a default element. | false |
AlertDialog.Content
The dialog body. Outside interaction is blocked.
| Prop | Type | Default |
|---|---|---|
| onOpenAutoFocus | (event) => voidCustomize initial focus. | — |
AlertDialog.Cancel
The cancelling action. Receives initial focus.
| Prop | Type | Default |
|---|---|---|
| asChild | booleanMerge props onto the immediate child instead of rendering a default element. | false |
AlertDialog.Action
The confirming action.
| Prop | Type | Default |
|---|---|---|
| asChild | booleanMerge props onto the immediate child instead of rendering a default element. | false |
AlertDialog.Title
Accessible dialog title.
| Prop | Type | Default |
|---|
AlertDialog.Description
Accessible dialog description.
| Prop | Type | Default |
|---|