Installation
Theme
Mode

Overlays & feedback

Confirm dialog

The focused “are you sure?” for actions you can’t take back — delete, discard, publish. A scrim, an icon that signals consequence, a clear question, and two buttons where the confirm carries the tone.

$npx shadcn@latest add @orbit/confirm-dialog

Tones

Live — danger, warning, and primary tint the icon and the confirm button, so the weight of the action reads before you read the words. Open one, then dismiss with Cancel, the scrim, or Escape; after confirming, a brief acknowledgement closes the loop.

Anatomy

A confirm dialog interrupts on purpose, so keep it to one clear question and two unambiguous choices. The 42px tinted icon signals consequence, the title asks the question, the message spells out exactly what’s affected and whether it’s reversible, and the footer sits on a muted strip with Cancel always one obvious move away.

Tone signals consequencedanger · warning · primary color the icon square and the confirm button.
One clear questionA title that asks, a sentence that names the scope — “and its 2 subtasks”.
Easy to back outCancel, the scrim, and Escape all dismiss without confirming.
Confirms the outcomeAfter acting, a brief acknowledgement (“Task deleted”) shows it worked.

Controlled

Omit trigger and drive open yourself to confirm actions that start elsewhere — a row’s delete button, a menu item, a keyboard shortcut.

API rate limiting
Design review notes
Ship onboarding flow

Props

PropTypeDefaultDescription
tone"danger" | "warning" | "primary""danger"Colors the icon and the confirm button by consequence.
titleReactNodeThe question — “Delete this task?”. Required.
messageReactNodeThe consequence — what’s affected and whether it’s reversible. Required.
confirmLabelstring"Confirm"Confirm button label. Name the action, not “OK”.
cancelLabelstring"Cancel"Cancel button label.
onConfirm() => voidCalled when the confirm button is pressed, right before the dialog closes.
onCancel() => voidCalled when the dialog is dismissed via Cancel, the scrim, or Escape.
triggerReactElementElement that opens the dialog — usually a Button. Omit when controlling open.
openbooleanControlled open state.
defaultOpenbooleanfalseInitial open state when uncontrolled.
onOpenChange(open: boolean) => voidCalled when the dialog opens or closes.
classNamestringExtra classes for the dialog card. Raw parts are exported as ConfirmDialogPrimitive.

Usage

Reserve it for consequential, irreversible, or hard-to-undo actions. For routine saves don’t interrupt; for a dismissible side task use a Drawer or Modal.

Do

Name the action on the button

“Delete task”, not “OK”. A specific verb lets people confirm by reading just the button.

Don’t

Confirm everything

Overuse trains people to click through. Reserve it for the irreversible; make routine actions undoable instead.

Do

State what’s affected

Spell out the scope — “and its 2 subtasks” — so there are no surprises about what the action touches.

Don’t

Make destructive the default

Don’t autofocus or color the page so the dangerous choice is the easy one. The safe path should win ties.

Keyboard & accessibility

Built on Base UI AlertDialog: role='alertdialog' with the title and message as the accessible name and description, focus trapped while open and returned to the trigger on close, and page scroll locked.

EscCancel and close
Click scrimCancel and close
TabMove between Cancel and Confirm
Enter / SpaceActivate the focused button