Confirmation Dialog
Ergonomic AlertDialog wrapper for destructive actions with async confirm.
Import
import { ConfirmationDialog } from "@cooud-ui/ui";
npx cooud-ui add confirmation-dialog
Examples
API Reference
Generated from the component's exported types.
ConfirmationDialogProps
Extends Omit<ComponentPropsWithoutRef<typeof AlertDialogContent>, "title" | "children">
| Prop | Type | Default | Description |
|---|---|---|---|
trigger | ReactNode | — | Element 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* | ReactNode | — | Dialog heading — labels the dialog for assistive tech (rendered as `AlertDialogTitle`). |
description | ReactNode | — | Supporting 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 | boolean | false | Style the confirm button as a destructive (red) action and default the header icon to a warning triangle. |
icon | ReactNode | — | Icon 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 | boolean | — | Controlled open state. Provide alongside `onOpenChange` to control the dialog externally. |
defaultOpen | boolean | false | Uncontrolled initial open state. |
onOpenChange | (open: boolean) => void | — | Called whenever the open state changes (opening, cancelling, or confirming). Dismissal is suppressed while a confirm promise is pending. |