Menu


Alert dialog


A modal that asks before something that cannot be undone: a title, what will happen, and a cancel and a confirm action. It closes only on them and Escape.

Customize the preview


Choices
View

Delete this project?

Website redesign and its 24 pages will be removed for everyone on the team. This cannot be undone.


Options


Alert dialog options
ChoiceValuesDefaultWhat it does
sizesmbk-modal--size-<value>smmdsm
The greatest width the panel takes: the modal’s two narrower widths, since the question is short.
inlinesmbk-modal--inlineOn or offOff
Shown in place with no scrim, for previews and documentation.

Partssmbk-modal__headersmbk-modal__iconsmbk-modal__titlesmbk-modal__bodysmbk-modal__footer

Examples


Usage

The question, what will happen, Cancel and the action. Shown in place here.

Delete this project?

Website redesign and its 24 pages will be removed for everyone on the team. This cannot be undone.


Sizes

The modal’s two narrower widths.

Delete this project?

Website redesign and its 24 pages will be removed for everyone on the team. This cannot be undone.


Delete this project?

Website redesign and its 24 pages will be removed for everyone on the team. This cannot be undone.


Brand confirm

The brand tone, for an action that cannot be undone but destroys nothing.

Send the invoice?

Northwind will get invoice 2026-114 for 4,200 euros by email. A sent invoice cannot be called back.


Without icon

The icon is optional.

Remove Ana Silva from the team?

Ana loses access to every project at once. You can invite them again later.


Guidelines


Purpose

Asks the reader to confirm before something that cannot be undone, such as deleting a project. It is a modal that stops the page, says what will happen, and offers two ways out: cancel, which harms nothing, and the action itself. Unlike the modal, it closes only on those two and Escape, never on a click beside it, so the question is never dismissed by accident.

When to use

  • Before deleting, removing or overwriting something the reader cannot get back.
  • Before an action that costs money or reaches other people and cannot be called back.

When not to use

  • A question with no lasting harm, or a small form: use a modal.
  • Telling the reader something happened: use a toast.
  • An action that can be undone: do it at once and offer Undo in a toast, rather than asking first.

Usage rules

Do

  • Ask only before what cannot be undone.
  • Say in the description exactly what goes ("Website redesign and its 24 pages").

Don't

  • Ask before everyday actions: an alert dialog asked too often is confirmed without reading.
  • Put a second destructive action in it.

Delete this project?

Website redesign and its 24 pages will be removed for everyone on the team. This cannot be undone.


Do

Name the action after what it does, so the reader knows the result before pressing it.

Delete this project?

Website redesign and its 24 pages will be removed for everyone on the team. This cannot be undone.


Don't

A "Yes" makes the reader reread the question to learn what pressing it will do.

Anatomy

  • The block, the modal's native dialog element over its scrim, with the alertdialog role. The modal's stylesheet draws it.
  • The header part: an optional icon part and the title part, the question, on one line. There is no close button. While the confirm action is the danger one, the icon is drawn in the danger color.
  • The body part: the description, what will happen, and anything more the question needs under it.
  • A divider and the footer part, holding the cancel action and then the confirm action, at the end.

Behavior

Opens modally, with focus on the cancel action. Pressing cancel or Escape asks to close; pressing the confirm action calls onConfirm and then asks to close. A click on the scrim does nothing. A dialog that holds its own open state closes itself; one the page holds waits for the page to close it, through onOpenChange(false). It fades in and rises into place over its scrim as the modal does, and under reduced motion fades in place. The size axis sets the greatest width, the modal's small or medium; the panel shrinks with the window.

The inline flag renders the panel in place with no scrim, so it can be seen in the Showroom and in documentation.

Accessibility


What it does for you

  • It has the alertdialog role, so a screen reader announces it as an alert: its title names it and its description is read with it as it opens.
  • Focus starts on the cancel action, the one that harms nothing, so pressing Enter by habit cancels. Focus is held inside while it is open and returns to the opener when it closes.
  • A click beside it never closes it, so the reader must choose.
  • The title is a second-level heading unless headingLevel gives another.

What you must do

  • Write the title as the question ("Delete this project?") and the description as what will happen, in a sentence or two.
  • Name the confirm action after what it does ("Delete project"), never "OK" or "Yes".
  • Give the cancel action's words in the page's own language when the page is not in English.

How to test

  • Press the control that opens it: focus is on the cancel action. Tab and Shift + Tab stay inside it.
  • With a screen reader, it is announced as an alert dialog with its title and its description.
  • Click on the scrim: it stays open. Press Escape: it closes, and focus returns to the opener.
  • With text at 200% and the page 320 pixels wide, the panel shrinks with the window and both actions stay reachable.

Keyboard

Alert dialog keys
KeyWhat it does
TaborShift+Tab
Moves focus between the actions and anything inside, and holds it there.
EnterorSpace
Presses the focused action. Cancel has focus as it opens.
Escape
Asks to close, as cancel does.

Source


The files the alert dialog is made of. Its folder on GitHub (opens in a new tab) holds them with its wrapper and its document.

Stylesheet
alert-dialog.css
/* smbk-alert-dialog — Alert dialog. The modal with the alertdialog role, drawn by the modal's stylesheet: its
 * markup carries the modal's block, size and part classes after its own mark, smbk-alert-dialog, so every rule of
 * modal/modal.css and the shared dialog/dialog.css (the scrim, the motion, the page held still) draws it.
 * This file holds no rules: the alert dialog's own class is only its mark in markup. */
Tokens it reads
Alert dialog tokens
Token and CSSValuePreviewFoundation
color.overlay.scrim--smbk-color-overlay-scrimlight: #00000080dark: #00000099changes with themeColor
motion.exit.duration--smbk-motion-exit-duration200msMotion
motion.exit.easing--smbk-motion-exit-easingcubic-bezier(0.7, 0, 0.84, 0)Motion
motion.enter.duration--smbk-motion-enter-duration320msMotion
motion.enter.easing--smbk-motion-enter-easingcubic-bezier(0.16, 1, 0.3, 1)Motion
space.8--smbk-space-88pxSpacing
space.16--smbk-space-1616pxSpacing
layer.modal--smbk-layer-modal1300Stacking order
space.stack.xl--smbk-space-stack-xlcomfortable: 24pxcompact: 16pxchanges with densitySpacing
size.modal.sm--smbk-size-modal-sm400pxSize
space.inset.2xl--smbk-space-inset-2xlcomfortable: 24pxcompact: 16pxchanges with densitySpacing
border-width.hairline--smbk-border-width-hairline1pxBorder width
color.border.rim--smbk-color-border-rimlight: #ffffffe6dark: #ffffff0dchanges with themeColor
radius.container.lg--smbk-radius-container-lg16pxRadius
color.surface.default--smbk-color-surface-defaultlight: #f3f5f8dark: #181a1cchanges with themeColor
color.text.default--smbk-color-text-defaultlight: #232527dark: #e7ebf0changes with themeColor
elevation.overlay--smbk-elevation-overlaylight: 0px 12px 16px 2px #373d431a, 0px 2px 8px 0px #373d4326dark: 0px 12px 16px 2px #00000026, 0px 2px 8px 0px #00000033Elevation
space.inline.lg--smbk-space-inline-lgcomfortable: 12pxcompact: 8pxchanges with densitySpacing
size.control.md--smbk-size-control-mdcomfortable: 40pxcompact: 32pxchanges with densitySize
space.inset.lg--smbk-space-inset-lgcomfortable: 12pxcompact: 8pxchanges with densitySpacing
size.icon.lg--smbk-size-icon-lg24pxSize
color.feedback.danger.icon--smbk-color-feedback-danger-iconlight: #cc0d0ddark: #fe7d6dchanges with themeColor
typography.heading-2xs-bold--smbk-typography-heading-2xs-bold-font-family--smbk-typography-heading-2xs-bold-font-size--smbk-typography-heading-2xs-bold-font-weight--smbk-typography-heading-2xs-bold-line-height--smbk-typography-heading-2xs-bold-letter-spacing--smbk-typography-heading-2xs-bold-text-transformfontFamily: Funnel Display, Funnel Display Fallback, system-ui, sans-seriffontSize: min: 18px · max: 24pxfontWeight: 700lineHeight: 1.2letterSpacing: 0px

The quick brown fox

Typography
color.border.subtle--smbk-color-border-subtlelight: #c4cdd8dark: #2d3237changes with themeColor
color.text.subtle--smbk-color-text-subtlelight: #4e555edark: #9ba5b1changes with themeColor
typography.body-sm--smbk-typography-body-sm-font-family--smbk-typography-body-sm-font-size--smbk-typography-body-sm-font-weight--smbk-typography-body-sm-line-height--smbk-typography-body-sm-letter-spacing--smbk-typography-body-sm-text-transformfontFamily: Geist, Geist Fallback, system-ui, sans-seriffontSize: 14pxfontWeight: 400lineHeight: 1.5letterSpacing: 0px

The quick brown fox

Typography
size.modal.md--smbk-size-modal-md560pxSize
size.modal.lg--smbk-size-modal-lg800pxSize
Manifest
alert-dialog.manifest.json
{
  "name": "alert-dialog",
  "block": "smbk-alert-dialog",
  "drawnBy": "smbk-modal",
  "summary": "A modal that asks before something that cannot be undone: a title, what will happen, and a cancel and a confirm action. It closes only on them and Escape.",
  "adapt": "css",
  "axes": {
    "size": {
      "values": [
        "sm",
        "md"
      ],
      "default": "sm",
      "description": "The greatest width the panel takes: the modal’s two narrower widths, since the question is short."
    }
  },
  "flags": {
    "inline": {
      "description": "Shown in place with no scrim, for previews and documentation."
    }
  },
  "parts": [
    "header",
    "icon",
    "title",
    "body",
    "footer"
  ],
  "figmaNodeId": "8224:3557"
}