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.

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.

PropTypeDefaultDescription
childrenReactNodeThe trigger element that opens the dialog
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