Alert dialog
A dialog that interrupts to confirm an action that cannot be undone.
In Multi-brand
See it live
npm run storybookWhen to use it
In Multi-brand: Cancel a plan.
- 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 Multi-brand uses it
Words
- Shared structure: object, state, next step.
- Brand tone lives in headlines and marketing copy, not in errors.
- Errors and confirmations read the same in every brand.
- Use: Get started, Plan, Order. Avoid: Brand-specific words in errors, Jargon.
The labels components use, from the voice tokens:
content.action.commit: Savecontent.action.cancel: Cancelcontent.action.destroy: Removecontent.action.retry: Try againcontent.action.empty-action: Get started
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.
Multi-brand decides what changes when you switch theme. Here a switch changes colors, type and shape, so the marked rows differ between its brands and 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.relaxed:320ms |
| Overlay | ||
| Fill Changes with theme | component.alert-dialog.overlay.backgroundcolor.surface.scrimvar(--alert-dialog-overlay-background) | Aster Lightblack.light.scrim:#0000008CAster Darkblack.dark.scrim:#000000B3Birch Lightblack.light.scrim:#0000008CBirch Darkblack.dark.scrim:#000000B3Coral Lightblack.light.scrim:#0000008CCoral Darkblack.dark.scrim:#000000B3 |
| Content | ||
| Gap | component.alert-dialog.content.gapspace.gap.groupvar(--alert-dialog-content-gap) | space.24:1.5rem |
| Corner Changes with theme | component.alert-dialog.content.radiusradius.containervar(--alert-dialog-content-radius) | Aster Lightradius.8:0.5remAster Darkradius.8:0.5remBirch Lightradius.16:1remBirch Darkradius.16:1remCoral Lightradius.20:1.25remCoral Darkradius.20:1.25rem |
| Fill Changes with theme | component.alert-dialog.content.backgroundcolor.surface.canvasvar(--alert-dialog-content-background) | Aster Lightslate-deep.light.50:#F8FAFCAster Darkslate-deep.dark.0:#020617Birch Lightslate-deep.light.50:#F8FAFCBirch Darkslate-deep.dark.0:#020617Coral Lightslate-deep.light.50:#F8FAFCCoral Darkslate-deep.dark.0:#020617 |
| Padding | component.alert-dialog.content.paddingcomponent-spacing-map.x6var(--alert-dialog-content-padding) | space.36:2.25rem |
| Shadow Changes with theme | component.alert-dialog.content.shadowelevation.overlayvar(--alert-dialog-content-shadow) | Aster Lightshadow.overlayAster Darkshadow.overlay-darkBirch Lightshadow.overlayBirch Darkshadow.overlay-darkCoral Lightshadow.overlayCoral Darkshadow.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.48:3rem |
| Footer | ||
| Gap | component.alert-dialog.footer.gapspace.gap.defaultvar(--alert-dialog-footer-gap) | space.12:0.75rem |
| Title | ||
| Text size | component.alert-dialog.title.font-sizetype.heading.font-sizevar(--alert-dialog-title-font-size) | font.size.20:1.25rem |
| 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.16:1rem |
| Text Changes with theme | component.alert-dialog.description.labelcolor.text.mutedvar(--alert-dialog-description-label) | Aster Lightslate-deep.light.600:#4B5A6FAster Darkslate-deep.dark.400:#96A3B5Birch Lightslate-deep.light.600:#4B5A6FBirch Darkslate-deep.dark.400:#96A3B5Coral Lightslate-deep.light.600:#4B5A6FCoral Darkslate-deep.dark.400:#96A3B5 |
| Media | ||
| Corner Changes with theme | component.alert-dialog.media.radiusradius.controlvar(--alert-dialog-media-radius) | Aster Lightradius.4:0.25remAster Darkradius.4:0.25remBirch Lightradius.12:0.75remBirch Darkradius.12:0.75remCoral Lightradius.999:9999pxCoral Darkradius.999:9999px |
| Fill Changes with theme | component.alert-dialog.media.backgroundcolor.surface.sunkenvar(--alert-dialog-media-background) | Aster Lightslate-deep.light.100:#F1F5F9Aster Darkslate-deep.dark.100:#1E293BBirch Lightslate-deep.light.100:#F1F5F9Birch Darkslate-deep.dark.100:#1E293BCoral Lightslate-deep.light.100:#F1F5F9Coral Darkslate-deep.dark.100:#1E293B |
| Size | component.alert-dialog.media.sizesize.control.defaultvar(--alert-dialog-media-size) | size.44:2.75rem |
| From the system | ||
| Edge Changes with theme | color.border.default straight from the system, through --border | Aster Lightslate-deep.light.200 · #E2E8F0Aster Darkslate-deep.dark.100 · #1E293BBirch Lightslate-deep.light.200 · #E2E8F0Birch Darkslate-deep.dark.100 · #1E293BCoral Lightslate-deep.light.200 · #E2E8F0Coral Darkslate-deep.dark.100 · #1E293B |