Confirm Dialog
UI SDK AlertDialog with an async confirm action: pending, no double submit, closes on success, inline error on failure, data-agent-confirm for destructive actions.
Example
confirm-dialog-demo.tsxCopy code
Installation
Copy code
Usage
ImportCopy code
API reference
ConfirmDialog
| Prop | Type | Default |
|---|---|---|
tone | "default" | "destructive" | "default" |
agentConfirm | string | – |
titlerequired | ReactNode | – |
description | ReactNode | – |
childrenA callout under the description, like "Three agents are still running on it": an Alert in the dialog's tone (`destructive`, or `info` for the default tone), read as part of the description. Text, or AlertTitle and AlertDescription parts. | ReactNode | – |
calloutToneThe callout's tone, when the dialog's doesn't fit. | Tone | – |
confirmLabelrequired | ReactNode | – |
labels | ConfirmDialogLabels | – |
cancelLabel@deprecated Use `labels.cancel`. | ReactNode | – |
onConfirmrequiredRuns before the dialog closes. A returned Promise keeps it open and pending; a rejection keeps it open. | ConfirmAction | – |
triggerContent of the button that opens the dialog. Omit it when opening through `open` or `controller`. | ReactNode | – |
triggerVariant | VariantProps<typeof buttonVariants>["variant"] | – |
triggerDisabledThe trigger can't open the dialog, like while the action isn't allowed; nor can an agent or a controller. | boolean | false |
triggerPendingWork the trigger stands for is running elsewhere, like a delete already sent: a spinner, `aria-busy`, and presses ignored while the trigger keeps focus, as `Button loading` does. The dialog doesn't open meanwhile. | boolean | – |
renderError | (error: unknown) => ReactNode | defaultRenderError |
className | string | – |
Also takes Pick< AlertDialogRootProps, "open" | "defaultOpen" | "onOpenChange" | "onOpenChangeComplete" | "controller" | "pendingAnnouncement" >.
Other exports
type ConfirmDialogLabelstype ConfirmDialogPropsAccessibility
- An alert dialog: async confirm with pending state, no double submit and an inline error on failure.
- Closes on success and returns focus to the trigger.
Agent actions
tone="destructive" requires agentConfirm, which becomes data-agent-confirm: agents need a person to approve.
Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.