Tool Call Card
A status card for a single tool call.
Usage
Basic
The host advances toolCall.status; the expanded body switches content with it.
Loading demo...
Best Practices
- Put structured results (a table, a chart, a widget) in the
resultslot and keepoutputas the plain-text fallback. - On
retry, setstatusback torunningright away so users don't click repeatedly. - Append logs line by line instead of replacing the block, so tail-following stays smooth.
- On non-English surfaces, override the label props (including
linesToggleFormatter) together to avoid a mixed-language card. - Write
summaryas what the call did, not the tool name again; the collapsed row is all users scan.
API Reference
Props
| Name | Type | Default | Description |
|---|---|---|---|
toolCall | AiToolCallPart | — | The call to render. Required. |
defaultExpanded | boolean | false | Initial expanded state; read once, on mount. |
userOpen | boolean | — | Host-held expanded state; wins over the reader's click and auto-expansion. Omit it to let the card own the state. |
retryLabel | string | 'Retry' | Label of the retry button. |
pendingLabel | string | 'Queued' | Label for pending. |
runningLabel | string | 'Running' | Label for running. |
doneLabel | string | 'Done' | Label for done and any unmatched status. |
errorLabel | string | 'Failed' | Label for error. |
inputLabel | string | 'Input' | Accessible name of the input section; not drawn as a heading. |
emptyResultLabel | string | 'No output' | Shown in the result area when a done call has no output and no input, and no result slot is given. |
showRetry | boolean | — | Shows the retry button; when unset, the button appears only if a retry listener is bound. |
linesToggleFormatter | (hiddenCount: number, expanded: boolean) => string | 'N more lines' / 'Show less' | Label of the toggle when the input runs past four lines. |
AiToolCallPart is { type, id, name, status, summary?, input?, output?, error?, logs?, durationMs? }, where status is 'pending' | 'running' | 'done' | 'error'.
Events
| Name | Payload | Description |
|---|---|---|
retry | (id: string) | Fires when retry is clicked, with toolCall.id. |
toggle | (expanded: boolean) | Fires when the header is clicked, with the new expanded state. |
Slots
| Name | Scope | Description |
|---|---|---|
summary | { toolCall } | Replaces the arguments text in the header (defaults to summary, then the first input line). |
result | { toolCall } | Result surface for the host's own rendering; replaces output when provided. |
icon | { status } | Replaces the status icon. |
CSS Variables
| Variable | Default | Description |
|---|---|---|
--tx-tool-call-card-log-color | #d6e2f0 | Text colour of the log area. |
Overview
- The body follows
status:runningshowslogs,doneshows theresultslot (falling back tooutput), anderrorshowserror;inputshows whenever it is set. - The header reads: elapsed time while in flight (
(1.0)), the name (shimmering while in flight), the arguments (summary, else the first input line), then the duration oncedurationMsis set. pendingandrunningauto-expand; once settled the card collapses and keeps the last two lines of output as a preview. Logs, output and the preview stay pinned to their bottom, and every change tologsscrolls the log region down.- Input longer than four lines shows its first four and a toggle built by
linesToggleFormatter; the footer shows the status. - The retry button appears only in the
errorstate:showRetrytrue shows it, false hides it, and when unset it shows only if aretrylistener is bound. statusis mirrored onto the root'sdata-statusfor styling.
Technologies
AiToolCallPartis defined and exported byai-elements.- Source:
packages/tuffex/packages/components/src/tool-call-card/.