Skip to content
KaUI is under active development. If you run into a bug, please open an issue.

Confirm Action

Guards irreversible actions behind a confirm dialog with built-in async loading state on the confirm button.

pnpm dlx shadcn@latest add @kaui/confirm-action
import { ConfirmAction } from "@/components/ui/confirm-action";
<ConfirmAction
title="Delete item?"
description="This action cannot be undone."
confirmText="Delete"
confirmVariant="destructive"
action={deleteItem}
onSuccess={() => toast.success("Deleted")}
>
<Button variant="destructive">Delete</Button>
</ConfirmAction>

The child element becomes the dialog trigger. Any clickable element works — a button, an icon, a menu item.

When you need to open the dialog from outside the component tree (a dropdown item, a context menu, a table row action), omit children and drive the dialog with open + onOpenChange instead:

const [open, setOpen] = useState(false);
<ConfirmAction open={open} onOpenChange={setOpen} action={deleteItem} />;

The trigger can be anything. Here a ghost trash icon appears on row hover , invisible until the user signals intent, then confirms before the action runs.

Pass any icon or image to media to give the dialog visual context. The icon renders in a muted tile beside the title, making the dialog feel grounded in the action it’s describing.

Use onSuccess to access the data returned by action , useful for showing a confirmation message with context from the server response.

onError fires if action throws. The dialog stays open so the user can try again without re-triggering the confirmation flow.

When the trigger lives outside the component e.g a dropdown item, a context menu, a table row action , pass open and onOpenChange instead of children. The component becomes purely a dialog; you control when it opens.

PropTypeDefaultDescription
childrenReactNodeTrigger element that opens the dialog. Omit when controlling open externally.
openbooleanControlled open state. Use when the trigger lives outside the component (dropdown item, context menu, table row action).
onOpenChange(open: boolean) => voidCalled when the dialog requests an open state change. Provide alongside open to manage the dialog externally.
action() => Promise<TData> | TDataAsync function executed when the user confirms
titleReactNode"Are you sure?"Dialog heading
descriptionReactNode"This action cannot be undone."Dialog body text
confirmTextReactNode"Continue"Label for the confirm button
cancelTextReactNode"Cancel"Label for the cancel button
confirmVariantButton variant"default"Visual style of the confirm button
loadingTextReactNodeconfirmTextText shown on the confirm button while the action runs
mediaReactNodeIcon or image rendered above the title inside the dialog
size"default" | "sm"Controls dialog width
onSuccess(data: TData) => voidCalled after action resolves , receives the return value
onError(error: TError) => voidCalled if action throws
onSettled(data, error) => voidCalled after either outcome