On this page
Overview
Show code, DeleteProject.tsx
Variants
- Neutral
An action people can get back from, such as archiving. The default.
- Danger
An action that deletes or ends something.
Show code, ArchiveProject.tsx
Anatomy
Dialog
Question
Description
Cancel
Confirm
Show code, ConfirmDialogAnatomy.tsx
Behaviour
Closing
A press outside doesn't close a ConfirmDialog.
An action that can fail
The dialog waits for its action, showing that it is working.
- When the action fails, it stays open with the error, so people can try again.
Show code, AsyncWithError.tsx
From a menu
A menu item can open the dialog, and focus returns to the menu's button when it closes.
Show code, FromMenu.tsx
Rules
Match the tone to the consequence, and let the buttons say what each choice does.
Use it when
- Deleting or ending something, once people read what it affects
- Confirming an action from a menu item, which can't confirm in place
- An action that takes a moment and can fail
Show code, DangerForDelete.tsx
Show code, NeutralForDelete.tsx
Content
Ask the question in the title, and name the consequence on the confirm button.
Show code, NameTheConsequence.tsx
Show code, YesNo.tsx
Accessibility
| Key | Action |
|---|---|
| Tab, Shift+Tab | Moves between Cancel and the confirm button; focus stays in. |
| Enter in a field of the content | Confirms, as the confirm button does. |
| Esc | Closes the dialog, unless the action is running. |