Destructive actions
Undo over confirm: make a destructive action reversible and offer Undo, and confirm only what cannot be taken back.
Make a destructive action reversible and offer Undo afterwards, rather than asking first. Confirm only the step that cannot be undone, and say exactly what it destroys.
Mail's conversations, as in the Mail demo. Archiving one, or deleting it into Trash, happens at once, with Undo in the toast: nothing is lost yet, so nothing is asked. Delete forever… cannot be undone, so it is the one step that asks, naming the conversation or how many go, and pointing at the way to keep them. A conversation that goes takes its button's focus with it, so the same button on the row now in its place takes it, as Accessibility asks.
Do and don't#
Ask a question that names the thing and the count, and label the button with the same verb: Delete 3 conversations.
Ask "Are you sure?" with OK: people learn to press it without reading.
Archive, move to the trash or hide, and toast with Undo. The fast path stays fast and a slip costs one tap.
Confirm every delete. A dialog on each one teaches people to click through it, so it no longer protects the one delete that mattered.
Which safeguard#
| The action | Can it be reversed? | Safeguard |
|---|---|---|
| Archive, hide, move to the trash, remove from a list | Yes | Do it, toast with Undo |
| Remove a past query from a search box's history | Yes, by searching it again | Do it, with no toast, see Search |
| Delete, where the app keeps a trash or history | Yes, from there | Do it, toast with Undo and say where it went |
| Discard unsaved edits by leaving | No | UnsavedChangesDialog, see Forms |
| Delete for good, empty the trash, revoke a token | No | ConfirmDialog with destructive |
| Delete something large or shared that others rely on | No | ConfirmDialog, and say what else goes with it |
The Settings demo's access tokens. A revoked token cannot be restored, and every script that signs in with it stops, so Revoke… asks first and says both.
ConfirmDialog asks no one to type a name back. It is sized for actions whose irreversible step
has a reversible alternative the wording can point at ("Archive it instead to keep its history").
An action with no such alternative, that destroys a lot, deserves more than this dialog.
A delete inside a Dialog, a Sheet or a menu follows the same table. Do it and toast with Undo while the overlay stays open: the toast comes up over it and takes the pointer there, and Undo runs without closing the overlay. From the keyboard Alt+T reaches it, and the focus comes back to the overlay afterwards.
Writing the confirmation#
- The title is the question, with the object: "Delete 3 conversations forever?", "Revoke the token for ci-runner?".
- The description says what cannot be undone and, if there is one, the reversible alternative. Where the title already says it all ("Discard changes?"), leave the description out: the title then stands straight over the buttons.
- The confirm button repeats the verb: Delete, Revoke. The cancel button is Cancel.
- The confirm button uses
destructive.ConfirmDialogopens with focus on Cancel, so a stray Enter cancels.
Placement#
- In a menu, a destructive item comes last, after a separator, with
variant="destructive". - In a toolbar or a row, a destructive action is a ghost or
destructivebutton away from the primary one, never the primary button itself. - Bulk actions say their count in the label: Delete 3 conversations.
On each platform#
Desktop & pointer#
- Undo is also a shortcut where the app has one (Ctrl+Z or ⌘Z) for the last destructive action.
- A row's delete button is always drawn, quiet and small, or waits in the row's
⋯menu: never only on hover.
Touch#
- Nothing appears only on hover: a row's delete action is always visible, or lives in the row's menu.
- A toast sits at the screen's edge, away from the thumb. Keep it up long enough for Undo to be reached, and offer the same undo where the item was, if the app has a place for it.
- A swipe that deletes is still followed by Undo: a swipe is easy to make by accident.
In the demos
- ReleasesRoll back, Promote, Retry and a tag act at once and offer Undo in their toast. Delete release… is the one step that asks, naming the release and what goes with it.
- SettingsDiscard changes in Profile acts at once and offers Undo. Revoke… a token is the one step that asks first, naming the token and that it cannot be restored.
- AdminIn Members, changing a role and revoking an invitation act at once and offer Undo in their toast. In Settings, Delete workspace… asks first, and Cancel deletion stands in its place for the thirty days before it goes.
- TasksSelect a few tasks and close them: they go at once, with Undo in the toast. Delete… is last in every row's menu, after a separator, and it is the one action that asks first, naming the tasks.
- MailArchive or delete a conversation: it moves at once, and the toast says where it went with Undo. In Trash, Delete forever… is the one step that asks, and it sits last in More actions.
- NotesMore actions → Delete note: the note goes at once, and Undo in the toast puts it back where it was. Nothing asks first.
- Config editorReview changes, then Discard changes: the edits go at once, and Undo in the toast brings them back. Only switching files over unsaved edits asks first.
- Binary inspectorEdit a few bytes: Undo takes each one back. Revert… drops them all, so it is the one step that asks, and its dialog points at Download as the way to keep a copy.