Skip to main content

Alert dialog

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

In Content first

See it live​

Start Storybook to see it live: npm run storybook

When to use it​

In Content first: The confirm after a delete that cannot be undone. Not for unsubscribing, which readers can undo.

  • 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 Content first uses it​

Delete or remove
Use Button secondary with the full verb, then confirm with Button danger
Not Button primary
Naming the verb and confirming prevents a mistake.
A confirmation question
Use Gentle and clear about what changes
Not Guilt or pressure
Readers come back when leaving felt respectful. Example: “Unsubscribe from the weekly letter? You can come back any time.”

Words​

  • Write to one person: "you", not "users".
  • Short sentences with room to breathe.
  • Explain why before asking for anything.
  • Use: Read, Save for later, You, Next issue. Avoid: Click here, Submit, Users, Content.

The labels components use, from the voice tokens:

  • content.action.commit: Save
  • content.action.cancel: Not now
  • content.action.destroy: Remove
  • content.action.retry: Try again
  • content.action.empty-action: Browse guides

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

Content first 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.

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)Lightblack.light.scrim:#0000008CDarkblack.dark.scrim:#000000B3
Content
Gapcomponent.alert-dialog.content.gapspace.gap.groupvar(--alert-dialog-content-gap)space.32:2rem
Cornercomponent.alert-dialog.content.radiusradius.containervar(--alert-dialog-content-radius)radius.12:0.75rem
Fill
Changes with theme
component.alert-dialog.content.backgroundcolor.surface.canvasvar(--alert-dialog-content-background)Lightstone.light.50:#FFFDF8Darkstone.dark.0:#14110D
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)Lightshadow.overlayDarkshadow.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.64:4rem
Footer
Gapcomponent.alert-dialog.footer.gapspace.gap.defaultvar(--alert-dialog-footer-gap)space.16:1rem
Title
Text sizecomponent.alert-dialog.title.font-sizetype.heading.font-sizevar(--alert-dialog-title-font-size)font.size.28:1.75rem
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.18:1.125rem
Text
Changes with theme
component.alert-dialog.description.labelcolor.text.mutedvar(--alert-dialog-description-label)Lightstone.light.600:#61594DDarkstone.dark.400:#A39A8B
Media
Cornercomponent.alert-dialog.media.radiusradius.controlvar(--alert-dialog-media-radius)radius.8:0.5rem
Fill
Changes with theme
component.alert-dialog.media.backgroundcolor.surface.sunkenvar(--alert-dialog-media-background)Lightstone.light.100:#F6F2EADarkstone.dark.100:#2E2A24
Sizecomponent.alert-dialog.media.sizesize.control.defaultvar(--alert-dialog-media-size)size.48:3rem
From the system
Edge
Changes with theme
color.border.default
straight from the system, through --border
Lightstone.light.200 · #E4DDD0Darkstone.dark.100 · #2E2A24