Alert dialog
A dialog that interrupts to confirm an action that cannot be undone.
In Dense data
See it live
npm run storybookWhen to use it
In Dense data: Confirms a delete.
- Use it when: Deleting, cancelling or overwriting something people cannot get back, when undo is not possible.
- Not when: Anything that can be undone (offer undo instead), or a form or task (use a dialog).
Instead:
- Dialog: A focused task, not a confirmation.
- Toast: Undo after the fact, when the action can be reversed.
How Dense data uses it
Words
- Lead with the object, then the state: "Alert 2041 contained."
- Use numbers, not words for numbers.
- One verb per button. No "please", no exclamation marks.
- Use: Investigate, Filter, Assign, Escalated, Resolved. Avoid: Oops, Awesome, Please, Simply.
The labels components use, from the voice tokens:
content.action.commit: Savecontent.action.cancel: Cancelcontent.action.destroy: Deletecontent.action.retry: Retrycontent.action.empty-action: Change filters
See Voice and tone for the whole voice.
Accessibility and keyboard
| Keyboard | What happens | Not |
|---|---|---|
| undefined | Escape cancels, the same as the safe choice. | undefined |
| undefined | Tab stays inside until people choose. | undefined |
Test before you ship:
- It is an alertdialog with a title and a description that names the consequence. undefined
- Focus starts on the safe choice, never on the destructive one. undefined
Use it in code
npx open-ds add alert-dialog
The component reads only component keys and semantic tokens, so it follows the brand and mode on <html>.
Tokens it reads
Alert dialog reads 17 tokens of its own, each an alias of a semantic token. Each row is one part: its own token, the semantic it aliases, and the value it ends at. Change a semantic and every component that reads it follows; override one of Alert dialog's tokens to change Alert dialog alone.
Dense data decides what changes when you switch theme. Here a switch changes colors only, so the marked rows differ between light and dark; everything else holds steady.
| Part | Its token and the semantic it aliases | Value |
|---|---|---|
| Shared | ||
| Transition panels duration | component.transition.panels-durationmotion.duration.panelsvar(--transition-panels-duration) | duration.fast:120ms |
| Overlay | ||
| Fill Changes with theme | component.alert-dialog.overlay.backgroundcolor.surface.scrimvar(--alert-dialog-overlay-background) | Lightblack.light.scrim:#0000008CDarkblack.dark.scrim:#000000B3 |
| Content | ||
| Gap | component.alert-dialog.content.gapspace.gap.groupvar(--alert-dialog-content-gap) | space.16:1rem |
| Corner | component.alert-dialog.content.radiusradius.containervar(--alert-dialog-content-radius) | radius.4:0.25rem |
| Fill Changes with theme | component.alert-dialog.content.backgroundcolor.surface.canvasvar(--alert-dialog-content-background) | Lightslate.light.50:#F7F8FADarkslate.dark.0:#0D1117 |
| Padding | component.alert-dialog.content.paddingcomponent-spacing-map.x6var(--alert-dialog-content-padding) | space.24:1.5rem |
| Shadow Changes with theme | component.alert-dialog.content.shadowelevation.overlayvar(--alert-dialog-content-shadow) | Lightshadow.overlayDarkshadow.overlay-dark |
| Header | ||
| Gap | component.alert-dialog.header.gapcomponent-spacing-map.x2var(--alert-dialog-header-gap) | space.8:0.5rem |
| Gap x | component.alert-dialog.header.gap-xspace.gap.sectionvar(--alert-dialog-header-gap-x) | space.24:1.5rem |
| Footer | ||
| Gap | component.alert-dialog.footer.gapspace.gap.defaultvar(--alert-dialog-footer-gap) | space.8:0.5rem |
| Title | ||
| Text size | component.alert-dialog.title.font-sizetype.heading.font-sizevar(--alert-dialog-title-font-size) | font.size.16:1rem |
| Weight | component.alert-dialog.title.font-weighttype.title.font-weightvar(--alert-dialog-title-font-weight) | font.weight.600:600 |
| Description | ||
| Text size | component.alert-dialog.description.font-sizetype.body.font-sizevar(--alert-dialog-description-font-size) | font.size.14:0.875rem |
| Text Changes with theme | component.alert-dialog.description.labelcolor.text.mutedvar(--alert-dialog-description-label) | Lightslate.light.600:#535D6DDarkslate.dark.400:#969FAD |
| Media | ||
| Corner | component.alert-dialog.media.radiusradius.controlvar(--alert-dialog-media-radius) | radius.2:0.125rem |
| Fill Changes with theme | component.alert-dialog.media.backgroundcolor.surface.sunkenvar(--alert-dialog-media-background) | Lightslate.light.100:#EEF1F5Darkslate.dark.100:#262D38 |
| Size | component.alert-dialog.media.sizesize.control.defaultvar(--alert-dialog-media-size) | size.32:2rem |
| From the system | ||
| Edge Changes with theme | color.border.default straight from the system, through --border | Lightslate.light.200 · #DDE2EADarkslate.dark.100 · #262D38 |