Approval Card
ProThe gate where an agent stops and a person decides: what will happen, how risky it is, and an explicit Approve or Reject.
Playground
Send 14 payment reminders
Low riskEmails the contact on every invoice more than 30 days overdue. Sent emails cannot be recalled.
POST /email/bulk to: 14 recipients template: invoice-overdue-30 dry_run: false
Send 14 payment reminders
Medium riskEmails the contact on every invoice more than 30 days overdue. Sent emails cannot be recalled.
POST /email/bulk to: 14 recipients template: invoice-overdue-30 dry_run: false
Send 14 payment reminders
High riskEmails the contact on every invoice more than 30 days overdue. Sent emails cannot be recalled.
POST /email/bulk to: 14 recipients template: invoice-overdue-30 dry_run: false
Send 14 payment reminders
Low riskEmails the contact on every invoice more than 30 days overdue. Sent emails cannot be recalled.
POST /email/bulk to: 14 recipients template: invoice-overdue-30 dry_run: false
Approved
Send 14 payment reminders
Medium riskEmails the contact on every invoice more than 30 days overdue. Sent emails cannot be recalled.
POST /email/bulk to: 14 recipients template: invoice-overdue-30 dry_run: false
Approved
Send 14 payment reminders
High riskEmails the contact on every invoice more than 30 days overdue. Sent emails cannot be recalled.
POST /email/bulk to: 14 recipients template: invoice-overdue-30 dry_run: false
Approved
Send 14 payment reminders
Low riskEmails the contact on every invoice more than 30 days overdue. Sent emails cannot be recalled.
POST /email/bulk to: 14 recipients template: invoice-overdue-30 dry_run: false
Rejected
Send 14 payment reminders
Medium riskEmails the contact on every invoice more than 30 days overdue. Sent emails cannot be recalled.
POST /email/bulk to: 14 recipients template: invoice-overdue-30 dry_run: false
Rejected
Send 14 payment reminders
High riskEmails the contact on every invoice more than 30 days overdue. Sent emails cannot be recalled.
POST /email/bulk to: 14 recipients template: invoice-overdue-30 dry_run: false
Rejected
Send 14 payment reminders
Low riskEmails the contact on every invoice more than 30 days overdue. Sent emails cannot be recalled.
POST /email/bulk to: 14 recipients template: invoice-overdue-30 dry_run: false
Expired without an answer
Send 14 payment reminders
Medium riskEmails the contact on every invoice more than 30 days overdue. Sent emails cannot be recalled.
POST /email/bulk to: 14 recipients template: invoice-overdue-30 dry_run: false
Expired without an answer
Send 14 payment reminders
High riskEmails the contact on every invoice more than 30 days overdue. Sent emails cannot be recalled.
POST /email/bulk to: 14 recipients template: invoice-overdue-30 dry_run: false
Expired without an answer
Installation
Approval Card comes with WunderUI Core and Pro, in the package from your plan. See the plans.
Then import what you need:
import { ApprovalCard } from "@wunderui/react"Then use it:
import { ApprovalCard } from "@wunderui/react"
export function Request({ onAnswer }: { onAnswer: (answer: "approved" | "rejected") => void }) {
return (
<ApprovalCard
title="Send 14 payment reminders"
summary="Emails the contact on every invoice more than 30 days overdue. Sent emails cannot be recalled."
risk="medium"
onApprove={() => onAnswer("approved")}
onReject={() => onAnswer("rejected")}
/>
)
}Expected result: You should see a card with a shield, the title, a Medium risk badge, the summary, and Approve and Reject buttons. Press one and the buttons give way to Approved or Rejected, and your handler runs.
When to use
Use Approval Card for
- A step an agent may not take without a person's yes: sending, deleting, paying, publishing
- A permission an agent asks for, an edit it proposes (with a diff) or a run that goes over its budget
- A request that can lapse, with the time left and a clear outcome when it does
Use something else for
- Tool Permission Row for a lasting Allow, Ask or Deny setting per tool
- Alert Dialog for a confirmation of the person's own action, outside an agent run
- Run Timeline for the steps of a run; the card goes inside the step that waits
Kind
The kind picks where the payload sits and how the buttons read. Inline and high cost keep the payload behind a disclosure, while diff and permission show it at once.
Send 14 payment reminders
Medium riskEmails the contact on every invoice more than 30 days overdue. Sent emails cannot be recalled.
POST /email/bulk to: 14 recipients template: invoice-overdue-30 dry_run: false
Edit the reminder template
Medium riskChanges the payment term in the template from 30 to 14 days. Every reminder sent after this uses the new text.
Please pay within 30 days.Please pay within 14 days.Read the billing ledger
Medium riskNeeded to find the invoices that are overdue and to send the reminders. The access ends with the run.
Requested access
- Read invoicesbilling · 128 open invoices
- Send emailinfo@wunderui.com · 14 recipients
Analyse 1,240 support reports
High riskReads every report and writes a summary for each one. You are charged per token read and written.
Estimated $18.40 · run budget $10.00
About 3× the usual run. Analysing 400 reports stays within the budget.
Risk
Risk is a label and a tint, not a lock: every level has the same two buttons. Write the summary so the consequence is clear before the person reaches them.
Publish the changelog entry
Low riskPushes the 0.2.0 notes to the docs site. Nothing else changes and the entry can be unpublished.
Send 14 payment reminders
Medium riskEmails the contact on every invoice more than 30 days overdue. Sent emails cannot be recalled.
Delete 312 draft invoices
High riskPermanently deletes every draft older than 90 days. This cannot be undone.
Actions
Approve and Reject are always side by side. Name them after what happens, add a softer second yes only where it is safe, and give Edit to a request that can change.
Send 14 payment reminders
Medium riskEmails the contact on every invoice more than 30 days overdue. Sent emails cannot be recalled.
Send 14 payment reminders
Medium riskEmails the contact on every invoice more than 30 days overdue. Sent emails cannot be recalled.
Send 14 payment reminders
Medium riskEmails the contact on every invoice more than 30 days overdue. Sent emails cannot be recalled.
Send 14 payment reminders
Medium riskEmails the contact on every invoice more than 30 days overdue. Sent emails cannot be recalled.
Expiry
A request can lapse. The card counts down, turns the time red in the last minute and resolves itself as expired without running anything, and your code is told once so the agent learns nobody replied.
Send 14 payment reminders
Medium riskEmails the contact on every invoice more than 30 days overdue. Sent emails cannot be recalled.
Send 14 payment reminders
Medium riskEmails the contact on every invoice more than 30 days overdue. Sent emails cannot be recalled.
Send 14 payment reminders
Medium riskEmails the contact on every invoice more than 30 days overdue. Sent emails cannot be recalled.
Resolved
Once a request is answered the card names the decision, resolvedBy says who made it and resolvedAt when. The leading slot puts a checkbox before the icon for a queue where several requests are answered together.
Send 14 payment reminders
Medium riskEmails the customers whose invoices are 30 days overdue.
Approved by Nora Lindgren · 2 min ago
Delete the branch fix/old-tokens
High riskRemoves the branch from the remote.
Rejected by Daniel Okafor · 14:02
Update 3 token files
Low riskWrites the new radius scale to styles.css.
Keyboard interactions
Every control is a native button, so the browser provides focus and activation. The card itself is not in the tab order: it takes focus only when your code focuses it.
- TaborShift+Tab
- Moves through the details toggle (inline and high-cost), then Approve, the second yes, Reject and Edit, in that order. Focus shows as an indigo border with a 2 px ring.
- EnterorSpace
- On Approve, Reject, the second yes or Edit: answers or runs it. On the details toggle: opens or closes the payload ( follows). After an answer, focus moves to the card.
- Esc
- Does nothing. An unanswered request stays open until it is answered or expires; closing it is not an answer.
Behavior and motion
What the card does when it is answered, controlled or left alone, and what it leaves to you.
- Answering
- Uncontrolled, the card resolves in place: Approve (and the second yes) approves, Reject rejects, then your handlers run. Edit calls its handler and leaves the request pending.
- Controlled
- When you set the state, the card shows exactly that. A press calls your handler but changes nothing and an expiry only calls the expire handler, so update the state when the decision is saved.
- Expiry
- An expiry starts a countdown (9m 00s left) that turns red under a minute and expires a pending card at zero. An answered card never expires; the expire handler runs once.
- First paint
- The countdown is empty on the server and the first client render, and fills in after mount, so the card never prints a stale time.
- Details
- In inline and high-cost kinds the preview sits behind a toggle that starts closed unless you open it by default. In dialog-diff and permission it is shown at once, and closed details are inert.
- Focus
- The card is a focusable group named by its title. Focus it when a request needs attention; after an answer or expiry focus moves to it unless your handler already moved it.
- Live region
- The card has no live region. A new card, an answer and an expiry are not announced, so mount a status line next to it before it has text and say what changed.
- Failure and abort
- Rejected means a person said no, Expired without an answer means nobody did, and in both nothing ran. Say what the agent does instead next to the card.
- Motion
- The details open smoothly and the chevron turns. Nothing else on the card moves.
- Reduced motion
- With reduced motion on, the details and chevron change at once. The countdown, the outcome and every state are unchanged.
Anatomy
The figure marks a pending card with its details closed. The cost banner and the outcome appear in other kinds and states, so they have no number.
Send 14 payment reminders
Medium riskEmails the contact on every invoice more than 30 days overdue. Sent emails cannot be recalled.
POST /email/bulk to: 14 recipients template: invoice-overdue-30 dry_run: false
- 1data-slot="approval-card"
A bordered, rounded card built as a labelled group named by its title. The border is indigo while pending and neutral after an answer, and the card takes focus by script, not by Tab.
- 2
A 32 px shield tile, tinted green, amber or red by risk. Decorative: the risk badge says the same in words.
- 3
The request in one line, 14 px semibold. It names the group for assistive technology.
- 4
Low risk, Medium risk or High risk (medium by default). It labels the request and does not change the buttons.
- 5Optional
One sentence, 13 px: what happens if the request is approved. Write the consequence, not the mechanism.
- 6Optional
The request time as you wrote it, then a clock and the time left (8m 56s left) while pending with an expiry set. The time turns red under a minute; the line is gone after an answer.
- 7Optional
The preview payload. In inline and high-cost kinds it sits behind a Show what will run toggle; in dialog-diff and permission it is shown at once.
- 8
Approve (filled), an optional softer secondary action, Reject (plain), and Edit if given. Labels follow the kind unless you pass your own, and after an answer the row becomes the outcome.
- Optional
In the high-cost kind with a cost: an amber banner with the estimate, the run budget and a note, shown above the details.
- Optional
Approved, Rejected or Expired without an answer, with a check, cross or clock in the outcome's colour. It replaces the buttons and does not name who decided: write that under the card.
Best practices
- Do
Write the summary as the consequence in one sentence (Sent emails cannot be recalled), set the risk honestly and put the exact payload in the preview so people can inspect what will run.
- Do
When the default words are too vague, name the buttons after what happens: Send 14 reminders, Don't send. Reject stays next to Approve, never in a menu.
- Do
When a request appears, move focus to the card, never to Approve, and say it in a status line. The card does not announce itself.
- Do
Write who decided and when as a line under the card, like Approved by Nora Lindgren at 14:02. The card shows the outcome; naming the person is up to you.
- Do
Set an expiry where requests lapse, and use the expire handler to tell your agent that nobody answered and nothing ran. Pass the expired state back so card and store agree.
- Do
Show two requests at once, oldest first, each on its own. Answering one never answers the other.
- Don’t
Don't start in the approved state or approve inside your own handler. A default yes removes the gate, and no button may take focus on its own.
- Don’t
Don't read high risk as a lock: it adds no confirmation and changes no button. For an action that cannot be undone, say so in the summary and on the button.
- Don’t
Don't offer a second yes such as Always allow on a high-risk request, and don't add a louder Approve elsewhere. A lasting yes is a decision of its own.
API reference
ApprovalCard is a plain component, so the table lists every prop.
A bordered, rounded card built as a labelled group named by its title. The border is indigo while pending and neutral after an answer, and the card takes focus by script, not by Tab.
| Prop | Type | Default | Description |
|---|---|---|---|
| title required | ReactNode | — | The request in one line. Also the accessible name of the card. |
| summary | ReactNode | — | One sentence: what happens if this is approved. |
| preview | ReactNode | — | The payload, diff or scopes behind the request, for example a pre block, a DiffView or a ScopeList. Behind a toggle in and , shown at once in and . |
| risk | "medium" | "low" | "high" | "medium" | , (default) or . Sets the label and the tint of the icon. It does not change the buttons. |
| kind | "inline" | "dialog-diff" | "permission" | "high-cost" | "inline" | (default), , or . Picks where the payload sits and the default button words. |
| expiresAt | Date | string | number | — | A , an ISO string or a timestamp. A pending card counts down to it and resolves as at zero (when is not set). is called at that moment either way. |
| state | "pending" | "approved" | "rejected" | "expired" | — | , , or . Pass it to control the card from your store; leave it out and the card resolves itself. |
| onApprove | () => void | — | Called when Approve is pressed, after the card has resolved (uncontrolled) or at once (controlled). |
| onReject | () => void | — | Called when Reject is pressed. |
| onExpire | () => void | — | Called once when passes while the card still waits for an answer, also in controlled mode. Store the outcome and stop the run here; set if you control the card. Not called for an answered card or again for the same time. |
| leading | ReactNode | — | A slot before the risk icon, for a selection checkbox in a queue. Not rendered when empty. |
| resolvedBy | ReactNode | — | Who decided, shown in the resolved line ("Approved by Nora Lindgren"). Text or an element. |
| resolvedAt | ReactNode | — | When it was decided, shown as given after the decision ("Approved by Nora Lindgren · 2 min ago"). |
| warnAt | number | 60_000 | Milliseconds left at which the countdown turns amber. Passed to the Expiry Timer inside the card. Default . |
| approveLabel | string | — | The text of the Approve button. Defaults per kind: Approve, Allow once, Allow, Run anyway. |
| cost | { estimate: ReactNode; budget?: ReactNode; note?: ReactNode } | — | For : , shown in an amber banner above the details. Nothing is drawn without it. |
| defaultOpen | boolean | false | Opens the details toggle on the first render, in and . by default. |
| onEdit | () => void | — | When given, an Edit button appears beside Reject. It leaves the request pending. |
| ref | Ref<HTMLDivElement> | — | Reaches the card. Call when a new request needs attention, instead of focusing Approve. |
| rejectLabel | string | — | The text of the Reject button. Defaults per kind: Reject, Reject, Deny, Cancel. |
| requestedAt | ReactNode | — | Shown as written next to the countdown, for example . Not formatted by the card. |
| secondaryAction | { label: string; onClick?: () => void } | — | . A softer second yes such as . It resolves the card as approved and calls its own , not . |
Notes for AI
Give your coding assistant the Markdown reference instead of screenshots.
get_component("approval-card")The full library index for assistants is at /llms.txt.
Related components
- Done420 tok$0.01640ms
Input
status: overdue, age: 30+ daysOutput
14 invoices, $42,860 in total - Done3,420 tok$0.042.1s
Input
14 invoice idsOutput
14 contacts, all with an email address - Running2,310 tok
Input
template: invoice-overdue-30 - Pending
Input
to: 14 recipients - PendingLog the result
AI & Agents5 stylesProRun TimelineEvery step of a run in order, with duration, tokens and expandable input/output.