Default
Show the codeHide the code
Default, code
<DialogTrigger><Button variant="destructive">Remove Tom Ellis</Button><AlertDialog {...args} /></DialogTrigger>A confirmation that interrupts: focus starts on Cancel, the action is a verb, Esc cancels.
These are the real React components. Use them with a mouse, touch or keyboard, and switch the theme and density for every example at once.
Default, code
<DialogTrigger><Button variant="destructive">Remove Tom Ellis</Button><AlertDialog {...args} /></DialogTrigger>Open, code
<DialogTrigger defaultOpen><Button variant="destructive">Remove Tom Ellis</Button><AlertDialog {...args} /></DialogTrigger>Not destructive, code
<DialogTrigger defaultOpen>
<Button variant="outline">Leave without saving</Button>
<AlertDialog tone="default" title="Leave this page?" description="Your draft is saved, so you can come back to it." actionLabel="Leave page" cancelLabel="Stay" onAction={() => {}} />
</DialogTrigger>The npm package isn’t published yet. When it is, this is the install line; until then, this page runs the same build of the package (from commit fa3abf8).
Install
npm i @superduperui/react @superduperui/tokensImport
import { AlertDialog } from "@superduperui/react"AlertDialog also takes the props of the React Aria component it’s built on.
| Prop | Type | What it does |
|---|---|---|
titlerequired | string | The question, as the dialog's heading ("Remove Tom Ellis?"). |
descriptionrequired | ReactNode | What happens, and whether it can be undone. |
actionLabelrequired | string | The action's label: a verb that names the result ("Remove member"), never "OK" or "Yes". |
onActionrequired | () => void | Called when the action is confirmed. The dialog closes afterwards. |
cancelLabel | stringDefault 'Cancel' | The safe choice, focused when the dialog opens. Default "Cancel". |
tone | 'destructive' | 'default'Default 'destructive' | destructive draws the action as a danger button. Default destructive. |
children | ReactNode | Extra content between the description and the buttons (e.g. a "type the name to confirm" field). |
isOpen | boolean | |
onOpenChange | (isOpen: boolean) => void |
Screen readers announce "Remove Tom Ellis?, alert dialog, Tom will lose access..." then "Cancel, button".
WCAG 2.2 AAA criteria the component meets in Comfortable density: 1.4.6, 1.4.9, 2.1.3, 2.3.2, 2.4.13, 2.5.5, 2.5.6, 2.3.3.
Compact density meets AA (2.5.8, 24px targets), not AAA.
Shared patterns it ships with: 3.3.6 (confirm before an irreversible action); 2.4.12.
| axe-core (WCAG A, AA, AAA and best practice) | 60 runs across every story, theme, density and width: 0 violations |
|---|---|
| Rendered text contrast | 55 text runs: 0 below 7:1, lowest 8.43:1 |
| Target size | 10 targets: 0 under 44px in Comfortable |
| Focus appearance (2.4.13) | 18 focus stops in 3 browser engines: all pass |
| Keyboard script | Chromium 5 of 5, Firefox 5 of 5, WebKit 5 of 5 |
Manual passes with VoiceOver and NVDA haven’t been done yet.
Each step is scripted and run in Chromium, Firefox and WebKit.
| Key | What happens |
|---|---|
| Tab | Tab reaches the trigger |
| Enter | Enter opens it with focus on Cancel, the least destructive action |
| Tab | Tab moves to the action |
| Tab | Tab wraps inside the dialog |
| Escape | Esc cancels and focus returns to the trigger |
The Figma component is AlertDialog, with Tone (Destructive, Default). The Figma library isn’t published yet.
Figma to code: Tone → tone (Destructive = "destructive", Default = "default"); Title → title; Description → description; Content → children when Show content; nested Cancel → cancelLabel; nested Action → actionLabel.