Approval card
A React component in Beamline's AI & agents category.
The agent stops and asks before it acts: what it wants to do, exactly what that changes, any choices it needs, and Approve or Reject; both run your callbacks with progress, a refusal says why with Retry, and a settled card folds to one line of record.
Use it for
- An agent asking permission before an action with side effects (send, update, delete).
- An agent needing a few choices from the person before it continues.
Not for
- Approving a whole multi-step plan before it runs (plan).
- Allowing one tool call inside a run log (tool-call's Allow/Deny).
- A suggestion the person may take or leave (recommendation-card).
- A destructive action the person starts themselves (confirm-morph or alert-dialog).
Anatomy
- header: icon tile, who is asking, the request as a question, description
- danger badge ("Can't be undone")
- details: what will happen (label · value)
- answers so far: from the second question on, each earlier answer is a small tag above the current question (Skipped when left blank); pressing one goes back to that question
- question step: counter and number-key hint, options (radios or checkboxes) with "Suggested", own answer
- reason step (Reject): what to do instead
- failure alert with Retry
- footer: Back, ⌘Enter hint, Reject, Next or Approve (or Hold to approve)
- settled record: Approved / Rejected, the request, the answers or the reason; when the card had a description or details it opens (a disclosure) to show exactly what was decided on
- keyboard hints (1–n to choose, ⌘Enter approves) wait for hover or focus inside the card and fold away in a room under 28rem and on touch
- narrow (under 28rem of its own width): the Can't be undone badge sits under the description; under 24rem each detail stacks its label over its value and long values (addresses, ids) wrap; the settled line puts the request under the decision when they do not fit side by side
Variants
- tone: neutral, danger (marked irreversible, red edge)
- confirm: click, hold (press and hold)
States
- asking
- question n of N
- answer missing (Next/Approve disabled)
- rejecting (reason field)
- pending (Approve or Send rejection shows progress, card aria-busy)
- error (alert with the reason, Retry)
- approved (settled line; opens to the details)
- rejected (settled line with the reason; opens to the details)
Keyboard
- 1–9 pick (radios) or toggle (checkboxes) an option while focus is in the question
- ↑ ↓ move between radios (Radix)
- Enter in the own-answer field moves to the next question
- ⌘/Ctrl+Enter approves once every required question is answered (click mode)
- Escape in the reason field goes back
- Focus moves to the next question's choice, into the reason field, and onto the settled line
- Enter or Space on a settled record opens or closes what it decided on
- The earlier answers are buttons: Enter on one goes back to its question
- A settled record is named by its visible decision and request; the configurable details cue is its accessible description.
Motion
A question comes in from the side the person stepped toward (Next from the end, Back from the start; a fade under reduced motion); the reason field and a failure grow into place (.enter-grow); the card's height eases to each new question and down to its record (useHeightMorph); a decision made while watching folds the card to its record with a fade and the status mark settles in; the record opens with .disclosure-panel. Buttons show progress (Button), the hold fill sweeps (HoldToConfirm). Choices, focus and aria change at once; only the picture settles.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
title / description / agent / details (required) | ReactNode / { label, value }[] | — | title: What the agent wants to do, as a question: "Send the renewal offer to 41 account owners?" description: Supporting text beneath the label or heading. Defaults to no supporting text. agent: Who is asking. Default "The agent". details: Exactly what approving will do. |
questions | ApprovalQuestion[] | — | Choices the person makes before approving, one step each. |
value / defaultValue / onValueChange | Record<questionId, { options: string[]; custom?: string }> | — | value: Controlled answers keyed by question id; omit to use defaultValue. defaultValue: Initial answers keyed by question id when uncontrolled. Defaults to an empty object. onValueChange: Reports answers keyed by question id after an edit; no callback by default. |
onApprove | (answers) => void | Promise | — | Runs the approval. Return a promise: the card shows progress, then the decision, or the reason it failed with Retry. |
onReject | (reason: string) => void | Promise | — | Runs the rejection with the person's reason (if they gave one). Same promise contract. |
decision / defaultDecision / onDecisionChange | "approved" | "rejected" | null | — | decision: The settled decision, controlled or not; a settled card folds to one line (history). defaultDecision: Initial recorded decision when uncontrolled. Defaults to null. onDecisionChange: Reports recorded decision after a change; no callback by default. |
tone / confirm / rejectReason / labels | "neutral" | "danger" / "click" | "hold" / boolean / Partial<ApprovalCardLabels> | — | tone: danger: the action is costly or cannot be undone; it is marked so. confirm: hold: approving needs a press and hold (for costly actions); click otherwise. rejectReason: Ask for a reason when rejecting. Default true. labels: Question, approval and rejection text overrides; defaults to the built-in English labels. |
style / ref | CSSProperties / native Ref | — | style: Inline styles on the documented visual root; no inline overrides by default. ref: Receives the documented root element; no ref by default. |
classNames | ApprovalCardClassNames | — | Classes for the named visual parts; no part overrides by default. |
style | CSSProperties | — | Inline styles on the documented visual root; no inline overrides by default. |
title (required) | ReactNode | — | What the agent wants to do, as a question: "Send the renewal offer to 41 account owners?" |
description | ReactNode | — | Supporting text beneath the label or heading. Defaults to no supporting text. |
agent | ReactNode | — | Who is asking. Default "The agent". |
details | ApprovalDetail[] | — | Exactly what approving will do. |
value | ApprovalAnswers | — | Controlled answers keyed by question id; omit to use defaultValue. |
defaultValue | ApprovalAnswers | — | Initial answers keyed by question id when uncontrolled. Defaults to an empty object. |
onValueChange | ((answers: ApprovalAnswers) => void) | — | Reports answers keyed by question id after an edit; no callback by default. |
decision | ApprovalDecision | null | — | The settled decision, controlled or not; a settled card folds to one line (history). |
defaultDecision | ApprovalDecision | null | — | Initial recorded decision when uncontrolled. Defaults to null. |
onDecisionChange | ((decision: ApprovalDecision | null) => void) | — | Reports recorded decision after a change; no callback by default. |
tone | "danger" | "neutral" | — | danger: the action is costly or cannot be undone; it is marked so. |
confirm | "click" | "hold" | — | hold: approving needs a press and hold (for costly actions); click otherwise. |
rejectReason | boolean | — | Ask for a reason when rejecting. Default true. |
labels | Partial<ApprovalCardLabels> | — | Question, approval and rejection text overrides; defaults to the built-in English labels. |
className | string | — | Classes on the documented visual root; no override by default. |
ref | Ref<HTMLElement> | — | Receives the documented root element; no ref by default. |
Built from
- radio-group
- checkbox
- input
- textarea
- hold-to-confirm
- alert
- badge
- kbd
- button
Dependencies
lucide-react, radix-ui
Import
import { ApprovalCard } from "@beamline/approval-card";
Get it
Approval card is part of Beamline UI. Install the parts you need in your React app as compiled packages or editable source. Get Beamline · Connect your agent
More in AI & agents
- Image generation: The frame an AI image is generated into: a field of brand-hued pixels breathes with the progress while the model works, then the image arrives —…
- Flowchart: A workflow as steps on a dotted canvas: a trigger, conditions that branch into paths side by side, actions and waits, read top to bottom; during a run…
- Run trace: One agent run as a waterfall: every step (model calls, tools, retrieval, checks, sub-agents) nested under the step that started it, each a bar on a…
- Run theatre: One agent run as a theatre: the Run trace's waterfall under a transport (play, scrub, speed) that replays the run as it happened. Pick a step and re-run…
- Answer compare: Two answers to the same prompt side by side, and a person's verdict: A is better, a tie, B is better, or both are bad, with the reasons that decided it…
- Branch navigator: The versions of an assistant conversation that forked when a message was edited or an answer regenerated: a “‹ 2 / 3 ›” switch on each message that has…
- Response: An assistant's answer as streamed markdown in the system's reading type: bursty tokens flow in at an even pace, each new word fades in through a short…
- Chat thread: People talking to people: messages grouped by person and day, reactions, delivery and read receipts that glide to the newest message read, who is typing…
- Model picker: Choose the AI model for a request by what it can do and what it costs: a trigger with the model's name opens a searchable list grouped by provider, with…
- Task rows: Background work an agent is doing, one row per task: status as a glyph and a word, what it produced, how long it has run or took, a progress bar while…
- Conversation: The scrolling column of a conversation: follows new content while you are at the bottom, stops when you scroll up to read, and offers a way back; shared…
- Context cards: The knowledge an agent retrieved before it answered: one card per chunk with what it is about, the text it read with the search words marked, how…
- Prompt suggestions: Ready-made prompts a person can start from or follow up with: chips, cards or a list; a picked one lifts off and flies into the composer as its text…
- Plan: An agent's plan: numbered steps with live status, progress, and Approve / Edit / Reject when it needs sign-off; approving shows progress, and a refusal…
- Tool call: One tool call in an agent's run: status, what it did and a short result on one quiet row that opens to the exact input and output; stops for permission…
- Recommendation card: One suggestion from the agent that the person may take or leave: what it suggests, why, the expected effect and how sure it is (a meter and a word…
- Citations: Inline numbered citations that preview their source on hover or focus, plus a numbered source list; streamed answers flow in at an even pace with the…
- Reasoning: The agent's trace, fed by your stream: a shimmering label and the seconds so far while it works, then "Thought for N seconds"; steps that check off…
- Attachment: A file tile: preview or typed glyph with the type named, name, size, upload progress, error with retry, and a keyboard-reachable remove.
- Prompt bar: The agent composer: a field that grows, @ to add a source, / for a command, a model picker, files and dictation, and one button that sends with progress…
- Selection actions: Select a passage and hand it to the agent: a bar over the selection with quick actions, your own instruction and More; while the agent works it says so…
- Message: One turn in a conversation with an agent: the person's words in a quiet bubble, the agent's answer on the page with its orb mark, trace, tool calls and…