Skip to main content

Dialog

A window over the page that takes attention until people finish or close it.

In Dense data

See it live​

Start Storybook to see it live: npm run storybook

When to use it​

In Dense data: Edit one record without leaving the table.

  • Use it when: People must decide or finish something before going back: a short form, an important choice.
  • Not when: A short status (toast), extra detail on the page (accordion), or a side panel that should not block the page (sheet).

Instead:

  • Sheet: A side panel; the page stays in view.
  • Toast: Does not interrupt.
  • Alert dialog: Confirms something that cannot be undone.

How Dense data uses it​

A menu or dialog
Use elevation.overlay and a dimmed page for dialogs
Not A border only
Floating things need a shadow so they read as on top.
Delete or remove
Use Button secondary, then confirm in a dialog with Button danger
Not Button primary as the first step
Deleting is rare and costly; a confirm step catches mistakes.

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: Save
  • content.action.cancel: Cancel
  • content.action.destroy: Delete
  • content.action.retry: Retry
  • content.action.empty-action: Change filters

See Voice and tone for the whole voice.

Accessibility and keyboard​

KeyboardWhat happensNot
undefinedEscape closes it.undefined
undefinedTab stays inside while it is open.undefined

Test before you ship:

  • It is a dialog with a title; the page behind is hidden from screen readers. undefined
  • Focus moves in when it opens and back to the trigger when it closes. undefined

Use it in code​

npx open-ds add dialog

The component reads only component keys and semantic tokens, so it follows the brand and mode on <html>.

Tokens it reads​

Dialog reads 20 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 Dialog's tokens to change Dialog alone.

Changes with theme

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.

PartIts token and the semantic it aliasesValue
Shared
Overlay background
Changes with theme
component.overlay.backgroundcolor.surface.raisedvar(--overlay-background)Lightslate.light.0:#FFFFFFDarkslate.dark.100:#262D38
Overlay radiuscomponent.overlay.radiusradius.containervar(--overlay-radius)radius.4:0.25rem
Overlay shadow
Changes with theme
component.overlay.shadowelevation.overlayvar(--overlay-shadow)Lightshadow.overlay:0px 8px 24px 0px #0D111729Darkshadow.overlay-dark:0px 8px 24px 0px #00000080
Overlay scrim
Changes with theme
component.overlay.scrimcolor.surface.scrimvar(--overlay-scrim)Lightblack.light.scrim:#0000008CDarkblack.dark.scrim:#000000B3
Content
Gapcomponent.dialog.content.gapspace.gap.groupvar(--dialog-content-gap)space.16:1rem
Paddingcomponent.dialog.content.paddingspace.inset.containervar(--dialog-content-padding)space.16:1rem
Text
Changes with theme
component.dialog.content.labelcolor.text.primaryvar(--dialog-content-label)Lightslate.light.900:#161B23Darkslate.dark.900:#F7F8FA
Dialog
Border widthcomponent.dialog.border-widthborder-width.defaultvar(--dialog-border-width)border-width.1:1px
Border
Changes with theme
component.dialog.bordercolor.border.defaultvar(--dialog-border)Lightslate.light.200:#DDE2EADarkslate.dark.100:#262D38
Cornercomponent.dialog.radiusradius.badgevar(--dialog-radius)radius.0:0rem
Paddingcomponent.dialog.paddingcomponent-spacing-map.x1var(--dialog-padding)space.4:0.25rem
Text
Changes with theme
component.dialog.labelcolor.text.secondaryvar(--dialog-label)Lightslate.light.700:#3D4655Darkslate.dark.500:#C4CBD6
Sunken
Changes with theme
on hover
component.dialog.sunkencolor.surface.sunkenvar(--dialog-sunken)Lightslate.light.100:#EEF1F5Darkslate.dark.100:#262D38
Sizecomponent.dialog.sizesize.iconvar(--dialog-size)size.16:1rem
Gapcomponent.dialog.gapspace.gap.tightvar(--dialog-gap)space.4:0.25rem
Gap 2component.dialog.gap-2space.gap.defaultvar(--dialog-gap-2)space.8:0.5rem
Font familycomponent.dialog.font-familytype.heading.font-familyvar(--dialog-font-family)font.family.ibm-plex-sans:"IBM Plex Sans", system-ui, sans-serif
Text sizecomponent.dialog.font-sizetype.heading.font-sizevar(--dialog-font-size)font.size.16:1rem
Weightcomponent.dialog.font-weighttype.heading.font-weightvar(--dialog-font-weight)font.weight.600:600
Font size 2component.dialog.font-size-2type.body.font-sizevar(--dialog-font-size-2)font.size.14:0.875rem