Skip to content
Overlays

Confirmation Dialog

Ergonomic AlertDialog wrapper for destructive actions with async confirm.

Import

tsx
import { ConfirmationDialog } from "@cooud-ui/ui";
bash
npx cooud-ui add confirmation-dialog

Examples

API Reference

Generated from the component's exported types.

ConfirmationDialogProps

Extends Omit<ComponentPropsWithoutRef<typeof AlertDialogContent>, "title" | "children">

PropTypeDefaultDescription
trigger
ReactNodeElement that opens the dialog. Rendered inside an `AlertDialogTrigger asChild`, so a single focusable child (e.g. a `Button`) is expected. Omit when driving the dialog purely via `open`.
title*
ReactNodeDialog heading — labels the dialog for assistive tech (rendered as `AlertDialogTitle`).
description
ReactNodeSupporting copy describing the consequence of the action (rendered as `AlertDialogDescription`).
confirmLabel
ReactNode"Confirm"Text for the confirm button.
cancelLabel
ReactNode"Cancel"Text for the cancel button.
destructive
booleanfalseStyle the confirm button as a destructive (red) action and default the header icon to a warning triangle.
icon
ReactNodeIcon shown in the header badge. Defaults to a warning triangle when `destructive`, otherwise none. Pass `null` to force it off.
onConfirm
() => void | Promise<void>Invoked when the user confirms. If it returns a promise, the confirm button shows a spinner and is disabled until it settles; on resolve the dialog closes, on reject it stays open and surfaces the error message.
open
booleanControlled open state. Provide alongside `onOpenChange` to control the dialog externally.
defaultOpen
booleanfalseUncontrolled initial open state.
onOpenChange
(open: boolean) => voidCalled whenever the open state changes (opening, cancelling, or confirming). Dismissal is suppressed while a confirm promise is pending.