Skip to main content

Alert dialog

A dialog that interrupts to confirm an action that cannot be undone.

In Multi-brand

See it live​

Start Storybook to see it live: npm run storybook

When 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​

Delete or remove
Use Button secondary, then confirm with Button danger
Not Button primary
Confirm before destroying data.
A confirmation question
Use Shared across brands: plain and specific
Not Brand tone when something is lost
Loss is never the moment for personality. Example: “Cancel your plan? It stays active until the end of the month.”

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: Save
  • content.action.cancel: Cancel
  • content.action.destroy: Remove
  • content.action.retry: Try again
  • content.action.empty-action: Get started

See Voice and tone for the whole voice.

Accessibility and keyboard​

KeyboardWhat happensNot
undefinedEscape cancels, the same as the safe choice.undefined
undefinedTab 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.

Changes with theme

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.

PartIts token and the semantic it aliasesValue
Shared
Transition panels durationcomponent.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
Gapcomponent.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
Paddingcomponent.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
Gapcomponent.alert-dialog.header.gapcomponent-spacing-map.x2var(--alert-dialog-header-gap)space.8:0.5rem
Gap xcomponent.alert-dialog.header.gap-xspace.gap.sectionvar(--alert-dialog-header-gap-x)space.48:3rem
Footer
Gapcomponent.alert-dialog.footer.gapspace.gap.defaultvar(--alert-dialog-footer-gap)space.12:0.75rem
Title
Text sizecomponent.alert-dialog.title.font-sizetype.heading.font-sizevar(--alert-dialog-title-font-size)font.size.20:1.25rem
Weightcomponent.alert-dialog.title.font-weighttype.title.font-weightvar(--alert-dialog-title-font-weight)font.weight.600:600
Description
Text sizecomponent.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
Sizecomponent.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