On this page

InstallationAnatomyEach part, and when it showsBefore a deletionA yes that is not redIts two buttons are ButtonsAt workA title aloneKeyboard and focusAccessibilityIn the dashboardAPI ReferenceModalConfirmationTokensRulesWritten downOpen questions

Modal confirmation

A question with a yes and a no, over the page, before something that cannot be undone. The second piece of the Modal.

1<ModalConfirmation2  open={open}3  onOpenChange={setOpen}4  title="Delete this agent?"5  description="Its keys stop working at once. This cannot be undone."6  confirmLabel="Delete"7  destructive8  onConfirm={remove}9/>

Installation

text
import { ModalConfirmation } from "@dome-systems/ds-dashboard/components";

It is new, and no screen draws it yet. It is in the Modal's file (ds/components/modal.tsx), built on the primitive shadcn's Alert Dialog uses (Base UI's), with the Card's title and description inside.

Anatomy

  1. 1 — The box. The Modal's box, 384px wide, padded 16px.
  2. 2 — Title. The question. 13px, medium.
  3. 3 — Description. What a yes does, in a sentence.
  4. 4 — No. Closes it. The focus lands here.
  5. 5 — Yes. Primary, or red when it destroys.

Each part, and when it shows

It is one component with a fixed shape: a title, a description and two Buttons. It has no header, no body, no footer and no X.

PartWhat it isWhen it shows
The coverBlack at 40% over the whole page, 60% in dark. A click on it does nothing.Under an open confirmation.
The boxThe Modal's box: the card's fill, 12px corners, the deepest of the four shadows. 384px wide, padded 16px.While open is true.
The titleThe question: 13px, medium.Always.
The descriptionWhat a yes does, in the secondary text color, under the title.When description is given.
The noA Button, at the left: the neutral one. “Cancel” unless cancelLabel says otherwise. It closes the confirmation. cancelButton passes it the Button's own props.Always.
The yesA Button, at the right: the primary one, red with destructive. “Confirm” unless confirmLabel says otherwise. confirmButton passes it the Button's own props.Always.

By their presets the two buttons are 28px tall. They are 12px apart, each takes half the width (170px), and they sit 16px under the text.

Before a deletion

A title, a description, and two buttons that share the width. The no comes first, and the focus lands on it. destructive is a preset: it makes the yes red. The yes does not close the confirmation: the screen decides when it is open, with open, and closes it when the work is done. While the work runs, the screen sets the yes's own loading and disables the no. A failure has no place in the confirmation: the screen reports it, with the toast every failed change uses.

1const [open, setOpen] = useState(false);2const [deleting, setDeleting] = useState(false);3
4async function remove() {5  setDeleting(true);6  try {7    await deleteAgent();8    setOpen(false);9  } catch (error) {10    toast(mutationFailureToast("agent", "delete", error));11  } finally {12    setDeleting(false);13  }14}15
16<ModalConfirmation17  open={open}18  onOpenChange={setOpen}19  title="Delete this agent?"20  description="Its keys stop working at once. This cannot be undone."21  confirmLabel={deleting ? "Deleting" : "Delete"}22  destructive23  confirmButton={{ loading: deleting, loadingPlacement: "before" }}24  cancelButton={{ disabled: deleting }}25  onConfirm={remove}26/>

A yes that is not red

Without destructive the yes is the primary button.

1<ModalConfirmation2  open={open}3  onOpenChange={setOpen}4  title="Rotate the signing key?"5  description="New tokens are signed with the new key. Tokens already issued stay valid until they expire."6  confirmLabel="Rotate"7  onConfirm={rotate}8/>

Its two buttons are Buttons

destructive and the two labels are presets. Anything else about a button is the Button's own prop, passed with confirmButton or cancelButton, over the preset: an icon, another emphasis, another size. The confirmation has no prop of its own for any of it.

1<ModalConfirmation2  open={open}3  onOpenChange={setOpen}4  title="Delete this agent?"5  description="Its keys stop working at once. This cannot be undone."6  confirmLabel="Delete"7  destructive8  confirmButton={{ iconStart: Trash }}9  cancelButton={{ emphasis: "ghost" }}10  onConfirm={remove}11/>

At work

The confirmation has no state of its own for this. A yes at work is the Button's loading, passed with confirmButton: here with loadingPlacement="before", the Loader, then the word, with no “…” after it. The screen disables the no with cancelButton. The two buttons keep their width, and the yes does not fire again. The Escape key still asks to close it: onOpenChange is called, and the screen may ignore it until the request ends.

1<ModalConfirmation2  open={open}3  onOpenChange={setOpen}4  title="Delete this agent?"5  description="Its keys stop working at once. This cannot be undone."6  confirmLabel="Deleting"7  destructive8  confirmButton={{ loading: true, loadingPlacement: "before" }}9  cancelButton={{ disabled: true }}10  onConfirm={remove}11/>

A title alone

The description can be left out when the title says it all.

1<ModalConfirmation2  open={open}3  onOpenChange={setOpen}4  title="Discard your changes?"5  confirmLabel="Discard"6  cancelLabel="Keep editing"7  destructive8  onConfirm={discard}9/>

Keyboard and focus

Measured in a browser, on the real confirmation.

KeyDoes
(on opening)The focus goes to the no. Measured with a mouse and a keyboard, not on a touch screen.
Tab, Shift + TabBetween the no and the yes: the focus stays in the confirmation.
Enter, SpacePresses the button that has the focus.
EscapeCloses it. The focus goes back to what opened it.

While it is open, the page behind does not scroll and does not answer the pointer. A click on the cover does not close it: the answer is one of the two buttons, or the Escape key.

Accessibility

A screen reader is told that it is an alert dialog (the role alertdialog). It reads the title as its name, and the description after it. The title is a level-2 heading. While it is open the rest of the page is hidden from a screen reader.

A yes whose Button is loading says it is busy. What a screen reader says when one opens was not tested.

In the dashboard

No screen draws the Modal confirmation yet. This is what the dashboard draws today in its place.

The shared confirmation

28 confirmations in 25 files draw ConfirmDialog: a title, a description, Cancel and a yes that is red when it destroys. 21 of them add a second, heavier line under the description. Their buttons are 32px.

components/shared/confirm-dialog.tsx

Alert dialogs written by hand

12 more are written one by one on the older Alert Dialog, in 10 files. Four of them hold a form or a list, which this piece does not take.

components/ui/alert-dialog.tsx

API Reference

ModalConfirmation

PropTypeDefaultDescription
openboolean—Required. Whether it is open: the screen decides.
onOpenChange(open, details) => void—Required. Called when it asks to close: the no, the Escape key. details.reason says which.
titleReactNode—Required. The question.
descriptionReactNode—What a yes does, in a sentence.
confirmLabelstring"Confirm"The yes.
cancelLabelstring"Cancel"The no.
destructivebooleanfalseA preset: the yes destroys something, so it is red.
confirmButtonButtonPresetProps—The yes's own props, over its preset: the Button's (iconStart, emphasis, size, loading, disabled…), each optional, with loadingPlacement still tied to its icons.
cancelButtonButtonPresetProps—The no's own props, over its preset: the Button's, as for the yes.
onConfirm() => void—Required. Runs on a yes. It does not close the confirmation: the screen does, when the work is done.

Tokens

The Modal's, in ds/tokens/modal.css: none is the confirmation's own.

TokenValueWhat it sets
--modal-backgroundThe card's fillThe box's fill.
--modal-shadowStacking level 4The box's edge and shadows.
--modal-backdropBlack at 40%, 60% in darkThe cover over the page (the backdrop).
--modal-width-sm384pxThe box's width.

Rules

Written down

Confirm only what cannot be undone

No “are you sure?” on a safe action. A confirmation is for a revoke, a rollback, a delete.

From design/principles.md (Voice & Posture).

The yes is at the right, the no at its left

The button that does the thing sits at the right. Cancel is the button at its left.

From design/principles.md (Forms).

A component that holds another passes it through

The confirmation holds two Buttons. It re-exposes none of their behavior as a prop of its own: destructive and the two labels are presets, and confirmButton and cancelButton pass the Button's own props.

From ui/ds/README.md (Components).

A button shows its own loading while its request runs

A yes at work is the Button's loading, set by the screen through confirmButton.

From .claude/rules/dashboard-ui.md (rule 6).

A failed change says so with the shared toast

A confirmation has no place for an error. When its yes fails, the screen reports it with mutationFailureToast, as every failed change does.

From ui/dashboard/CLAUDE.md (Failed-mutation toasts).

Open questions

They are on the Modal's page, each with a picture. Three of them are about this piece too: whether its buttons are 28px or 32px, whether it gets a row for an error, and whether it is called Modal confirmation or Alert dialog.