Tool call card
A structured execution card for inspecting tool invocations and gating sensitive mutations with human-in-the-loop approval. It pairs an explicit status label and glyph with monospace JSON argument and result blocks, one-click copy buttons, and Approve or Reject actions when awaiting confirmation. For multi-step thought traces without approval gates, use the reasoning panel.
Install
npx shadcn@latest add @thrum-pro/tool-call-cardThis is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.
Automatically installs icons chevron-down, circle-check, circle-slash, circle-x and terminal from the icon set.
Data shape
type ToolCallStatus = "running" | "awaiting" | "success" | "error" | "rejected";
type ToolCallArgs = Record<string, unknown> | string | null;const args = {
charge_id: "ch_3Q9x2L8vK1",
amount_cents: 4900,
currency: "usd",
};Props
| Prop | Type | Default | Description |
|---|---|---|---|
name | string | Required | Monospace tool identifier such as "sql.query_revenue" or "stripe.create_refund". |
status | ToolCallStatus | Default "success" | Execution state: running, awaiting, success, error or rejected. Always shown with a glyph and a word. |
args | Record<string, unknown> | string | null | – | Input parameters formatted as monospace JSON with a copy button. |
result | unknown | – | Output payload formatted as monospace JSON with a copy button when no error is set. |
error | string | null | Default null | Failure message rendered in a destructive-tinted code block with a copy button. |
durationMs | number | null | Default null | Execution time in milliseconds, formatted as ms below 1 second or seconds above. |
expanded | boolean | – | Controlled expanded state for the payload drawer. Pair with onExpandedChange. |
defaultExpanded | boolean | Default false | Whether the payload drawer starts open when uncontrolled. |
onExpandedChange | (expanded: boolean) => void | – | Called when the reader expands or collapses the payload drawer. |
onApprove | () => void | – | Called when the reader clicks Approve & run while status is "awaiting". |
onReject | () => void | – | Called when the reader clicks Reject while status is "awaiting". |
approvalPrompt | string | Default "Review parameters before running this action." | Short guidance line displayed in the approval footer. |
approveLabel | string | Default "Approve & run" | Text on the primary confirmation button. |
rejectLabel | string | Default "Reject" | Text on the outline rejection button. |
paused | boolean | Default false | Freezes the spinner animation while status is "running". |
sound | boolean | Default true | Plays open/close on toggle, select on approve, error on reject/failure, and success on completion. |
className | string | – | Merged onto the outer panel container. |
Motion and sound
Motion
- Expanding and collapsing the Arguments and Result drawer animates height and opacity over 250 ms.
- The header chevron rotates 180 degrees over 150 ms.
- While running, the status spinner turns continuously; paused freezes it in place.
- Reduced motion: disclosure changes settle immediately and the spinner stops rotating.
Sound
- Expanding the payload drawer plays open; collapsing plays close.
- Approving a pending tool call plays select; rejecting plays error.
- Transitioning from running to success plays success; transitioning from running to error plays error.
Sound is off until the visitor turns it on. Pass sound={false} to keep this component silent. How sound works
Accessibility
- The header is a native button with aria-expanded and aria-controls linked to the collapsible payload body.
- Every lifecycle state pairs a distinct indicator (spinner, amber disc, check, cross, slash) with an explicit status word, never relying on colour alone.
- Formatted JSON blocks are keyboard-scrollable with tabIndex=0 and pair with labelled CopyButton controls.
- The outer frame carries data-surface="panel" and status chips use foreground ink on tinted card fills, keeping 4.5:1 contrast across Solid and Frosted glass materials.
| Keys | Action |
|---|---|
| Tab / Shift Tab | Move between the header disclosure trigger, copy buttons, scrollable JSON blocks, and Approve / Reject buttons. |
| Enter / Space | Expand or collapse the card, copy a payload, or trigger Approve / Reject. |
Source
The source comes with Pro
TypeScript source · Copy-paste ready · MIT-compatible for client projects · Includes all dependencies
Files and dependencies
- Adds
components/ui/tool-call-card.tsx- Packages
motion- Brings along
- ButtonCopy buttonSpinnerChart foundationsMotion tokensSound engine
- Icons
chevron-downcircle-checkcircle-slashcircle-xterminal
Changelog
- 1.0.0 · 2026-12-04First release.