Confirmation dialogs
Components: Dialog, Drawer, Button, Input, Toast, Toaster
A confirmation dialog asks one question about one action, then runs that action or cancels it. Compose it from Dialog parts. There is no ConfirmDialog, AlertDialog, useConfirm or UnsavedChangesDialog.
When to use
Rules
Structure
- Import every
Dialog*part from@wallarm-org/design-system/Dialog.Dialogis not exported from the package root. - Use
width={400}for delete, state change and proceed-anyway. Omitwidth(560) for type-to-confirm and unsaved changes. Never use960for a confirmation. - Write the width as a number;
DIALOG_SIZESand asizeprop do not exist. If the description wraps, keep 400. - Footer order, left to right: Cancel, then confirm. The confirm button is always rightmost.
- Confirm buttons use the default
variant='primary'. Every other footer button isvariant='ghost' color='neutral'. - Never use
color='destructive'for an action that grants access or creates something. - Wrap Cancel in
DialogClose asChild. Never wrap the confirm button inDialogClose: it closes the dialog before the request runs. - Never add a close button to
DialogHeader. It renders the close X itself. - There is no
onConfirm,onCancel,confirmLabel,destructiveorloadingprop onDialog, noDialogAction/DialogCancel, and no initial-focus prop.
Spacing
- The parts own all padding (header
pt-20 pb-16 px-24, bodypx-24 py-8, footerpx-24 py-16 gap-8). Keep the body's 8px though Figma draws the input flush. - Never add
p-*,gap-*orspace-y-*around dialog content, wrap footer buttons in adiv/HStack, or passsizeto them (default 36px). - Never pass
classNametoDialogHeader,DialogBodyorDialogFooter. They take onlychildrenandref.
Behavior
- While the request runs, pass
loading={pending}to confirm (it also disables it; do not adddisabled={pending}) and ignore close requests. Close only on success; on failure keep it open with an error toast. - If the dialog closes, reset the type-to-confirm input to
''. Match the entity name exactly, case-sensitive. - If the dialog opens from a
Drawer, render it insideDrawerContent. See Layering. - To guard unsaved changes, intercept
onOpenChange(false)on theDrawer. One handler covers the close X,Escapeand outside click. - Never open a confirmation from a toast or from another confirmation.
- Use one controlled
openstate per dialog, set by the control that starts the action.
Copy
- Title is
<Verb> <object>?in sentence case. Confirm repeats that verb and noun without?. - Name the specific object in the description, and end with what can be undone or what is kept. If nothing can be undone, write "You can't undo this."
- If Figma's confirm label differs from the title ("Delete rule?" / "Delete permission"), use the title's noun.
Examples
A delete confirmation with pending, success and failure handling.
Opened from a row's actions menu, which sets the selected user and the dialog's own open
state. While the request runs, Escape and outside clicks are ignored; on success the row is
removed.
A state change that grants access uses the default brand confirm.
The description says what the user gets back. Once active, the same button deactivates: that dialog uses a destructive confirm and says the roles and data are kept.
Type-to-confirm omits width and keeps confirm disabled until the name matches.
For a delete that also breaks linked objects. The match is exact and case-sensitive, and
closing the dialog resets the input to ''.
An unsaved-changes guard intercepts the drawer's close and renders the dialog inside DrawerContent.
While the form is dirty, the close X, Cancel, Escape and an outside click all open the same
dialog. "Keep editing" returns to the form; "Leave without saving" drops the edits.
States
What your app owns
- The request,
pendingstate, error handling and blocking close while pending. - Type-to-confirm matching and resetting the input on close.
- Dirty tracking (your form library's flag) and intercepting the drawer close.
- Route changes and tab close from a dirty form: use your router's blocker and
beforeunload. The design system does not handle them. - Result toasts:
useToastfrom@wallarm-org/design-system/Toast, with oneToasterat the app root. - All copy, including entity names.
Related
- Action-result toasts: the toast after a confirmed action.
- Entity detail drawer: opens delete and state-change dialogs from its Actions menu.
- Create and edit forms: forms that need the unsaved-changes guard.
- Layering: nesting a
Dialoginside aDrawer. - Spacing and Typography: the dialog's built-in padding and text styles.