Example#
Delete the draft?
This cannot be undone.
Usage#
Use a dialog to stop and ask for one decision or one short task: confirm a delete, rename a project, add a person. The page behind goes inert under a scrim, focus moves in, and Escape or a close key brings people back to where they were.
- Parts.
DialogTrigger,DialogContent(sizesm,mdorlg; a close key by default),DialogTitle(required),DialogDescription,DialogBody,DialogFooterandDialogClose. alertmakes an alert dialog for destructive confirmations: no closing by a press outside.- The footer puts actions at the end, the main one last; below 30rem they stack full width with the main one at the bottom, in thumb reach.
- Long forms or anything people move between is a
Draweror its own page. Never open a dialog from a dialog more than once.
Anatomy#
Delete the draft?
This cannot be undone.
- PlateRaised surface, 2 px ink rule, 28, 36 or 48 rem wide.
.mk-dialog-popup - TitleThe question, in the card head role.
.mk-dialog-title - Close keyQuiet, at the top end.
.mk-dialog-close - FooterActions at the end, the main one last.
.mk-dialog-footer
Volume#
Reading layer: identical at every volume.
Quiet
Delete the draft?
This cannot be undone.
Studio
Delete the draft?
This cannot be undone.
Press
Delete the draft?
This cannot be undone.
Rave
Delete the draft?
This cannot be undone.
Content#
- The title asks the question or names the task: "Delete the draft?"
- The description says the consequence: "This cannot be undone."
- Keys say what they do: "Delete the draft" and "Keep it", never "OK" and "Cancel".
Do and don't#
Do
Delete the draft?
This cannot be undone.
Don't
Are you sure? [OK] [Cancel]
Accessibility#
- Focus moves to the first focusable element (or
initialFocus), Tab cycles inside, Escape closes and focus returns to the trigger. - The popup is named by DialogTitle and described by DialogDescription;
alertmakes an alertdialog that an outside press cannot close. - It portals with its trigger's scope, so a dialog opened in a Night section prints on Night.
- Below 30rem the footer stacks with the primary action at the bottom, in thumb reach.
| Keys | What happens |
|---|---|
| EnterorSpace on the trigger | Opens the dialog; focus moves to its first focusable element |
| TaborShift+Tab | Cycle inside the dialog (focus is trapped) |
| Escape | Closes it; focus returns to the trigger |
The colour pairs it prints, with their contrast on both papers:
| Text | Surface | Role | Bone | Night |
|---|---|---|---|---|
--mk-text | --mk-surface-raised | ui | not in this look | not in this look |
--mk-text-2 | --mk-surface-raised | ui | not in this look | not in this look |
Props#
| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | none | |
defaultOpen | boolean | none | |
onOpenChange | ((open: boolean) => void) | none | |
alert | boolean | none | `role="alertdialog"`; an outside press does not close it. |
children required | ReactNode | none |
Tokens#
System tokens (29)
--mk-border--mk-dur-overlay-in--mk-dur-overlay-out--mk-dur-reduced--mk-ease-out--mk-font-display--mk-font-text--mk-radius-plate--mk-scrim--mk-shadow-pop--mk-space-2--mk-space-3--mk-space-4--mk-space-6--mk-surface-raised--mk-text--mk-text-2--mk-track-head-card--mk-type-body-ui-leading--mk-type-body-ui-size--mk-type-body-ui-weight--mk-type-head-card-leading--mk-type-head-card-size--mk-type-meta-leading--mk-type-meta-size--mk-type-meta-weight--mk-wd-head-card--mk-wght-head-card--mk-z-overlay
Its own properties (3)
--mk-dialog-close-room--mk-dialog-pad--mk-dialog-w
Changelog#
Arrived in 0.1.0.
- The reading layer's controls, overlays, forms and visitor prefs (P2-T1 to P2-T5): every Button is the comic hit key, with IconButton, Link and Tooltip; Input, Textarea, Select, Checkbox and CheckboxGroup, Radio and RadioGroup, Switch, Slider with the ruler, RulerReadout and SegmentedControl; Dialog, Drawer, NavSheet, Tabs, Disclosure, Faq and faqJsonLd on Base UI 1.9 where the platform falls short; Field, Fieldset, Form with the site's inline validation, ErrorSummary, Callout, Honeypot, FormTimestamp and QuoteForm; PrefsScript under 1 KB, usePref and setPref with cross-tab sync, ThemeToggle and the visitor VolumeDial; VisuallyHidden.