Patterns
Destructive confirmation
An action destroys data or can't be reversed. People need one deliberate step, with the consequence spelled out, before it happens.
Reference build
Live, built only from system components. Switch the width: the build uses its own breakpoints.
Rules
- When the confirmed action changes the object on the page (decline, archive), show the new state where the old one was: the status in PageHead changes and the action disappears or is disabled. Use onConfirm for it, not successMessage under the trigger.
- Use Dialog with tone="danger"; never the browser's confirm() or alert().
- The title is a question that names the thing: “Delete project “Atlas”?”
- The body says what will be lost and whether it can be undone, in one or two sentences.
- The confirm label repeats the verb and the object (“Delete project”), never “OK” or “Yes”.
- The cancel label says what keeps the current state (“Keep project”).
- Only for actions that can't be undone. If there is an undo, act directly and offer the undo instead.
Layout and states
What every build of this pattern must hold to. The check runs the required states on the reference build.
- A danger trigger where the object is shown; the dialog names the object, says what is lost and offers keep and delete.
- The dialog takes the width of the screen; its buttons stack with the safe choice first in reading order.
| State | Proves |
|---|---|
| dialog-open | The dialog opens with its title naming the object and both choices. |
Code
import { Dialog } from "@/ds";
export function Example() {
return (
<Dialog
trigger="Delete project"
title="Delete project “Atlas”?"
tone="danger"
confirmLabel="Delete project"
cancelLabel="Keep project"
>
All requests, files and notes of this project are deleted. This can’t be undone.
</Dialog>
);
}Built from
Seen in: CRM window.confirm (S3), cockpit alert() (S4).