Confirm Button
Button wrapper that asks for confirmation before executing actions.
Default
Destructive confirmation flow for delete actions.
Items remaining: 3
default-example.tsx
1"use client";23import { useState } from "react";4import { ConfirmButton } from "@/registry/ui";56export function ConfirmButtonDefaultExample() {7 const [count, setCount] = useState(3);89 return (10 <div className="flex flex-col items-center gap-3">11 <p className="text-sm text-muted-foreground">Items remaining: {count}</p>12 <ConfirmButton13 label="Delete item"14 onConfirm={() => setCount((prev) => Math.max(0, prev - 1))}15 />16 </div>17 );18}
Soft Action
Non-destructive confirmation style for archive workflows.
soft-example.tsx
1"use client";23import { ConfirmButton } from "@/registry/ui";45export function ConfirmButtonSoftExample() {6 return (7 <div className="flex justify-center">8 <ConfirmButton9 label="Archive"10 variant="outline"11 title="Archive this conversation?"12 description="You can restore it later from archived items."13 confirmLabel="Archive"14 onConfirm={() => Promise.resolve()}15 />16 </div>17 );18}
Installation & source
Install via the shadcn CLI or copy the registry files manually.
bash
npx shadcn@latest add @tt-ui/confirm-button
Props
| Name | Type | Default | Description |
|---|---|---|---|
| onConfirm | () => void | Promise<void> | Required | Callback executed after confirming the action |
| label | string | "Delete" | Text shown on the trigger button |
| description | string | "This action cannot be undone." | Confirmation helper copy shown inside the popover |