Skip to content
Eskais UI

Overlays

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

Installation

npx shadcn@latest add @eskais/confirm-dialog

Usage

Import
import { ConfirmDialog } from "@/components/ui/confirm-dialog"

API reference

ConfirmDialog

PropTypeDefault
tone"default" | "destructive""default"
agentConfirmstring–
titlerequiredReactNode–
descriptionReactNode–
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–
confirmLabelrequiredReactNode–
labelsConfirmDialogLabels–
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–
triggerVariantVariantProps<typeof buttonVariants>["variant"]–
triggerDisabledThe trigger can't open the dialog, like while the action isn't allowed; nor can an agent or a controller.booleanfalse
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) => ReactNodedefaultRenderError
classNamestring–

Also takes Pick< AlertDialogRootProps, "open" | "defaultOpen" | "onOpenChange" | "onOpenChangeComplete" | "controller" | "pendingAnnouncement" >.

Other exports

type ConfirmDialogLabelstype ConfirmDialogProps

Accessibility

  • 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.