Skip to content
WunderUI

Approval Card

Pro

The 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

Medium risk

Emails the contact on every invoice more than 30 days overdue. Sent emails cannot be recalled.

2 min ago
POST /email/bulk
to: 14 recipients
template: invoice-overdue-30
dry_run: false

Installation

Approval Card comes with WunderUI Core and Pro, in the package from your plan. See the plans.

Then import what you need:

tsx
import { ApprovalCard } from "@wunderui/react"

Then use it:

tsx
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 risk

Emails the contact on every invoice more than 30 days overdue. Sent emails cannot be recalled.

2 min ago
POST /email/bulk
to: 14 recipients
template: invoice-overdue-30
dry_run: false

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 risk

Pushes the 0.2.0 notes to the docs site. Nothing else changes and the entry can be unpublished.

2 min ago

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 risk

Emails the contact on every invoice more than 30 days overdue. Sent emails cannot be recalled.

2 min ago

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 risk

Emails the contact on every invoice more than 30 days overdue. Sent emails cannot be recalled.

2 min ago

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 risk

Emails the customers whose invoices are 30 days overdue.

Approved by Nora Lindgren · 2 min ago

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.

TaborShiftTab
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 risk

Emails the contact on every invoice more than 30 days overdue. Sent emails cannot be recalled.

2 min ago
POST /email/bulk
to: 14 recipients
template: invoice-overdue-30
dry_run: false
  • data-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.

  • A 32 px shield tile, tinted green, amber or red by risk. Decorative: the risk badge says the same in words.

  • The request in one line, 14 px semibold. It names the group for assistive technology.

  • Low risk, Medium risk or High risk (medium by default). It labels the request and does not change the buttons.

  • Optional

    One sentence, 13 px: what happens if the request is approved. Write the consequence, not the mechanism.

  • Optional

    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.

  • Optional

    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.

  • 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.

PropTypeDefaultDescription
title requiredReactNode—The request in one line. Also the accessible name of the card.
summaryReactNode—One sentence: what happens if this is approved.
previewReactNode—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.
expiresAtDate | 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.
leadingReactNode—A slot before the risk icon, for a selection checkbox in a queue. Not rendered when empty.
resolvedByReactNode—Who decided, shown in the resolved line ("Approved by Nora Lindgren"). Text or an element.
resolvedAtReactNode—When it was decided, shown as given after the decision ("Approved by Nora Lindgren · 2 min ago").
warnAtnumber60_000Milliseconds left at which the countdown turns amber. Passed to the Expiry Timer inside the card. Default .
approveLabelstring—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.
defaultOpenbooleanfalseOpens 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.
refRef<HTMLDivElement>—Reaches the card. Call when a new request needs attention, instead of focusing Approve.
rejectLabelstring—The text of the Reject button. Defaults per kind: Reject, Reject, Deny, Cancel.
requestedAtReactNode—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.

MCPget_component("approval-card")
InstallIncluded in Core and Pro

The full library index for assistants is at /llms.txt.