When to use
- An agent wants to write a file, change a record or send something, and the person should see exactly what changes.
- Human-in-the-loop tools in
awaiting-approval.
When not to use
- A yes/no question with nothing to diff: use a confirm dialog or an Ask-User card.
Installation
pnpm dlx shadcn add @eased-pro/approval-cardnpx shadcn add @eased-pro/approval-cardyarn dlx shadcn add @eased-pro/approval-cardbunx --bun shadcn add @eased-pro/approval-cardInstalls from the @eased-pro registry and MCP server. · Already have Pro? Sign in.
Install the dependencies
pnpm add motion diffnpm install motion diffyarn add motion diffbun add motion diffAdd the Eased pieces it builds on
Copy each item’s files the same way, or install them with the CLI:
Add the files
- components/eased/approval-card/approval-card.tsx
Source is included with Eased Pro. Members download the files with the CLI command above, or through the MCP server.
Keep the folder layout
The files import each other by relative path (
../lib/motion), so keep each one at the path shown, undercomponents/eased/.
Usage
import { ApprovalCard } from "@/components/eased/approval-card/approval-card";<ApprovalCard title="Update the Team plan" description="Existing subscribers keep their price until renewal." files={[{ path: "src/billing/plans.ts", before, after }]} expiresAt={Date.now() + 5 * 60_000} onApprove={() => addToolApprovalResponse({ id, approved: true })} onDeny={() => addToolApprovalResponse({ id, approved: false })}/>API reference
ApprovalCard
| Prop | Type | Default | Description |
|---|---|---|---|
title | string | What it will do. | |
description | ReactNode | Why, in one muted line. | |
files | ApprovalFile[] | { path, before, after } or { path, hunks: DiffHunk[] }. | |
state | ApprovalState | uncontrolled | awaiting-approval, running, done, denied, error, expired. |
onApprove | () => void | Promise | A promise shows "Applying…" until it settles. | |
onDeny | () => void | ||
expiresAt / onExpire | number / () => void | A ring drains toward it. | |
expiresIn | number | Milliseconds from mount, in place of expiresAt. | |
holdMs | number | 800 | |
context | number | 2 | Context lines around each change. |
open | boolean | true | Show the body while pending; false leaves the header (a queue's closed rows). |
icon | ReactNode | A 16px glyph in place of the shield while pending. | |
meta | ReactNode | Muted text after the title, e.g. "Billing agent · 6 min ago". It truncates before the title, and hides under 30rem. | |
keys | { approve?, deny? } | { approve: "y", deny: "n" } | The keys that approve (held) and deny while focus is inside the card. |
actions | ReactNode | More footer actions after Deny, e.g. an Edit button. | |
tabIndex / ref | number / Ref<HTMLDivElement> | Make the card itself focusable, e.g. the open card in a queue. |
toDiffHunks(before, after, context?) is exported for your own diff views. The diff scrolls past 8rem; set --approval-diff-max on the card (className="[--approval-diff-max:14rem]") to give it more room.
Keyboard
| Key | Action |
|---|---|
Space / Enter (held) on Approve | Approves when the hold completes; release early to cancel. |
Y (held) | Same, while focus is inside the card. keys changes it. |
N | Denies, while focus is inside the card. keys changes it. |
Accessibility
- The card is a
groupnamed by its title; the diff is atablewith added and removed lines labelled. The outcome is announced from a status region. Approve explains its hold througharia-describedby. An empty diff disables Approve and says why inline.
Motion
The hold fills a brand layer across the button left to right in exact time (linear, 800ms), revealing the label in on-brand ink; letting go drains it on a 0.3s spring with no overshoot. Deciding folds the body on Auto Height while the header's mark swaps (the check draws) and the title gains its outcome through Text Swap. Reduced motion keeps the fill (it is information) and drops the swaps to fades.
Notes for AI
Always pass the real before/after text so the diff is the body; keep description to one sentence. Wire onApprove to the AI SDK approval response.
Do not add a separate confirm dialog: the hold is the confirmation.
Related components
- AI Tool Call Row: the row the call becomes once decided.
- Dynamic Island Activity Pill
- AI Agent Steps Timeline