Approval card
Approval card
The agent asks before it acts: what it wants to do, the details, Approve or Deny.
Dependencies
Interaction states
- pending — The request with its details and Deny / Approve. With expiresAt, a countdown whose digits roll down each second (00 rolls back to 59, like a clock).
- approved — One motion over 480ms: the body folds shut and blurs out, the padding tightens, the action slides into the header line, the label morphs to "Approved" and an emerald check draws itself in place of the shield.
- denied — Folds the same way into "Denied" with a ban icon; the agent carries on without it.
- expired — The countdown reaches 0:00, folds away with the body, and the label morphs to "Expired".
Installation
Add this component with your preferred package manager.
pnpm dlx shadcn@4.21.5 add @cavemio/approval-cardFirst install? Configure @cavemio once
Run npx shadcn@4.21.5 init if shadcn is not set up, then merge this entry into the registries field in your existing components.json. Keep your other settings and registries.
{
"registries": {
"@cavemio": "https://registry.cavemio.dev/r/cavemio-{name}.json"
}
}Where it’s used
AI agent chats
Ask before the agent sends an email, deletes files or spends money.
Payments and billing
Ask before a refund, a plan change or a large payment goes out.
Workflow tools
A step that waits for a person’s go-ahead before the run continues.
Admin tools
A sign-off before something that can’t be undone, such as deleting a project.
What it handles
- It says what will happen — A title, a description and a list of the specifics worth checking, such as recipients, amounts or files.
- Approve or Deny — Name the real action (“Send” and “Don’t send”) and get onApprove or onDeny back.
- Red for irreversible — Set destructive for deletes and payments and Approve turns red.
- It becomes the receipt — The same card folds into one line, “Approved” with a drawn check, rather than being swapped for something new.
- Requests can expire — A countdown rolls down like a clock and the card folds into “Expired” when it reaches zero.
- Hard to approve by accident — Approve is never focused automatically, so a stray Enter can’t approve an action.
Usage
Interactive local fixture. Data and async results are simulated in the preview; the caller supplies application services.
import { ApprovalCard } from "@/components/approval-card";
<ApprovalCard
title="Send email to 3 people"
description="The agent drafted a follow-up and wants to send it from your address."
details={[
{ label: "To", value: "maya@acme.com, +2 more" },
{ label: "Subject", value: "Thursday tasting menu" },
]}
onApprove={send}
onDeny={skip}
/>Props
| Prop | Type | Description |
|---|---|---|
| title / description | string | – · What the agent wants to do, in plain words. |
| details | { label; value }[] | – · The specifics worth checking: recipients, amounts, files. |
| reason | string | – · Why approval is needed, e.g. the AI SDK’s requestReason. |
| status / defaultStatus | "pending" | "approved" | "denied" | "expired" | "pending" · Controlled, or let the card remember the choice. |
| onApprove / onDeny | () => void | – · Send the decision back to your agent. |
| approveLabel / denyLabel | string | "Approve" / "Deny" · Name the actual action, e.g. "Send" and "Don’t send". |
| destructive | boolean | false · Red Approve for deletes, payments and other irreversible actions. |
| expiresAt / onExpire | number / () => void | – · Countdown to when the request lapses. |
Accessibility & motion
- The card is a labelled group in every state; the outcome is announced from a status region inside it, so screen readers hear "Approved: Send email to 3 people". - When you answer, focus moves to the card itself rather than dropping to the page as the buttons fold away. The folded body is inert. - The countdown is not a live region, so it never chatters; its digits are hidden from assistive tech and the time is real text. - Installs Number roll and Text morph. With reduced motion, the card changes state in place. - Approve is never focused automatically, so a stray Enter can’t approve an action. - Details wrap rather than truncate, because they are what the user is approving.
pnpm dlx shadcn@4.21.5 add @cavemio/approval-card