AlertDialog
A modal confirmation dialog that traps focus, prioritizes the safe cancel action, and requires an explicit decision.
Base AlertDialog interrupts the user for an explicit confirmation before a sensitive or irreversible action. It blocks outside dismissal and focuses the cancel action by default to prevent accidental confirmation.
Preview
Section titled “Preview” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
Installation
Section titled “Installation”Available starting in 0.3.0-rc.1 and later releases.
Anatomy
Section titled “Anatomy”Compose Root, Trigger, Mask, Content, Title, Description, Cancel, and Action:
Rootmanages open state with alertdialog semantics.Maskrenders the modal backdrop;Contenttraps focus, blocks outside-click dismissal, and focusesCancelfirst when available.- Activating
Actionemits theactionevent before requesting close; your application handles the underlying side effect. - Pressing
Escapeor activatingCancelrequests dismissal.
Controlled and uncontrolled state
Section titled “Controlled and uncontrolled state”- Pass
openfor controlled mode: listen toopenChangeand supply the next boolean value to commit state changes. - Omit
openfor uncontrolled mode and optionally passdefaultOpen. - Setting
disabledprevents command activation.
Root Props
Section titled “Root Props”Passing open selects controlled mode.
| Prop | Type | Default |
|---|---|---|
open | boolean | — |
defaultOpen | boolean | false |
disabled | boolean | false |
a11yLabel | string | '' |
Other parts
Section titled “Other parts”- Mask: accepts
passthrough(defaultfalse) plus the Transition props. - Content: accepts the Transition props.
- Trigger, Title, Description, Cancel, Action: no props.