Skip to content
ArcadiaDesign
Try it

TSX

confirm() resolves true on confirm and false on cancel or Esc. Requests queue, one dialog at a time, and render through one <ConfirmHost/> mounted at the app root; without it, confirm() rejects. Say what happens on the button ("Delete", "Discard"), never "OK".

Confirm, Dialog or Tray? Confirm only to stop something that can't be undone. A Dialog is for a task with its own controls. A question the product asks during work belongs in a Tray docked to the composer, where it doesn't block the page.

Examples

Async confirm

Return a promise from onConfirm: the button shows its loading state and closing is blocked; a rejection keeps the dialog open with its message. This one fails half the time.

States

Rendered open in place, set down in their frames.

Default: focus starts on the action
Danger: focus starts on Cancel
Loading: closing is blocked
Failed: the message stays

An alertdialog, named by its title and described by its description, that ignores clicks outside. Initial focus lands on Cancel for danger and on the confirm button otherwise, so a stray Enter never deletes anything. Focus returns to the button that asked.

Enter
Confirms, unless focus is on another button
Esc
Cancels
Tab
Moves between Cancel and the action

ConfirmDialog

open
boolean
defaultOpen
booleanDefault false
onOpenChange
(open: boolean) => void
onOpenChangeComplete
(open: boolean) => void
Called after the close animation.
onConfirm
() => unknown
Runs on confirm. A returned promise shows the loading state; a rejection keeps the dialog open and shows its message. The dialog closes when it resolves.
onCancel
() => void
loading
boolean
Controlled loading state (overrides the async one).
error
ReactNode
Controlled error message (overrides a caught rejection).
modal
booleanDefault true
false for inline previews.
initialFocus
ComponentProps<typeof DialogContent>["initialFocus"]
Override the initial focus (default: Cancel for danger, else the confirm button; false leaves focus where it is, for inline previews).
container
PortalContainerDefault document.body
Portal container.
titlerequired
ReactNode
description
ReactNode
confirmLabel
stringDefault "Confirm"
Say what happens: "Delete", "Discard changes".
cancelLabel
stringDefault "Cancel"
tone
"neutral" | "danger"Default "neutral"
children
ReactNode
Extra content between the description and the actions (a "don't ask again" switch).

titlerequired
ReactNode
description
ReactNode
confirmLabel
stringDefault "Confirm"
Say what happens: "Delete", "Discard changes".
cancelLabel
stringDefault "Cancel"
tone
"neutral" | "danger"Default "neutral"