Confirm dialog
ProOne dialog for "are you sure?": a question, what will happen, and two actions, locked while the action runs, with a failure kept inside it. Not an M3 component (@windmorph/react-pro).
import { ConfirmDialog, ConfirmDialogActions } from '@windmorph/react-pro';Part of Windmorph Pro, paid components on the free core, not on sale yet. See the Pro guide for what it includes and to register interest.
Keyboard
| Key | Action |
|---|---|
| Tab or Shift + Tab | Move between the content and the two actions, inside the dialog. |
| Enter or Space | Press the focused action. |
| Escape | Backs out, as Cancel does. Does nothing while the action runs. |
Focus starts on Cancel, so Enter right after it opens backs out rather than acts.
Screen reader
- Role
- An
alertdialog, modal: the rest of the page is hidden from assistive tech while it is open. - Accessible name
- Named by
titleand described bydescription. The acting button is named byconfirmLabel; the other bylabels.cancel("Cancel"). - States announced
- While the action runs the acting button says so in its name ("Remove, Loading", from
labels.pendingor the core Button's word) and stays focusable; Cancel is disabled.
- A failure (
error) is analert, announced once as it appears, and again if a retry fails the same way. - The
iconabove the title and the scrim are decorative and hidden from assistive tech (aria-hidden). - With
destructivethe label still names the action, so the colour isn't the only sign.
Focus
- It opens with focus on Cancel, the least destructive choice, as the ARIA alert dialog pattern asks.
initialFocusmoves it to the acting button, or to the first control in the content for a field that must be filled first. - Focus stays inside the dialog. While the action runs it stays on the acting button, which is pending, not disabled.
- After a failure, focus moves to the acting button, so Enter tries again.
- Closing returns focus to what opened it. When the action removed that element (a deleted row's button), move focus yourself in
onClosed.
Touch target
Both actions are Buttons, each with its own 48px touch target.
Motion
- It moves as the core
Dialogdoes, and only fades under reduced motion.instantturns every motion off. - The failure's alert fades in, under reduced motion too: a fade is not movement.
What you need to do
- Write
titleas the question, naming the thing ("Remove Alex from the team?"), andconfirmLabelas what happens ("Remove"), never "OK" or "Yes". - Say what will happen in
description, and whether it can be undone. - Give the failure's words through
error, saying what to do next ("That didn't work. Try again."). - Translate
labels.cancelandlabels.pending, or set them once for the app with aLabelsProvider.