Skip to content

Confirm dialog

Pro

One 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

Confirm dialog keyboard
KeyAction
Tab or Shift + TabMove between the content and the two actions, inside the dialog.
Enter or SpacePress the focused action.
EscapeBacks 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 title and described by description. The acting button is named by confirmLabel; the other by labels.cancel ("Cancel").
States announced
While the action runs the acting button says so in its name ("Remove, Loading", from labels.pending or the core Button's word) and stays focusable; Cancel is disabled.
  • A failure (error) is an alert, announced once as it appears, and again if a retry fails the same way.
  • The icon above the title and the scrim are decorative and hidden from assistive tech (aria-hidden).
  • With destructive the 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. initialFocus moves 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 Dialog does, and only fades under reduced motion. instant turns every motion off.
  • The failure's alert fades in, under reduced motion too: a fade is not movement.

What you need to do

  • Write title as the question, naming the thing ("Remove Alex from the team?"), and confirmLabel as 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.cancel and labels.pending, or set them once for the app with a LabelsProvider.