Tool Call Card
A tool call's status card, with logs that follow their tail and a result surface the host can own.
Tool Call Card
Basic Usage
Tool Call Card
Loading demo...
Interaction Contract
- Expanded state is owned by the component and seeded from
defaultExpanded. It is uncontrolled — changing the prop later has no effect. - Clicking the header toggles it and emits
togglewith the state after the change. statushas four values —pending,running,done,error— mirrored ontodata-statusfor styling. Their labels come frompendingLabel/runningLabel/doneLabel/errorLabel, all English by default.- The status label resolves through a
defaultbranch:pending,runninganderrormatch explicitly, and anything else falls through todoneLabel. - Every change to
toolCall.logsscrolls the log region to the bottom, so a running call follows its own tail like a terminal. retrycarriestoolCall.idrather than the whole object — a retry usually needs only the identifier.- The result area falls back in three stages: the
resultslot when a host mounts one, otherwiseoutput, anderrorwhenstatusiserror.
API
Props
| Name | Type | Default | Description |
|---|---|---|---|
toolCall | AiToolCallPart | — | The call to render: { type, id, name, status, summary?, input?, output?, error?, logs? }. Required. |
defaultExpanded | boolean | false | Initial expanded state. Read once, on mount. |
retryLabel | string | 'Retry' | Label for the retry button. |
pendingLabel | string | 'Queued' | Label for the pending status. |
runningLabel | string | 'Running' | Label for the running status. |
doneLabel | string | 'Done' | Label for done, and for any unmatched status. |
errorLabel | string | 'Failed' | Label for the error status. |
inputLabel | string | 'Input' | Heading for the input section. |
Events
| Name | Payload | Description |
|---|---|---|
retry | (id: string) | Emitted when retry is clicked, carrying toolCall.id. |
toggle | (expanded: boolean) | Emitted when the header is clicked, carrying the resulting state. |
Slots
| Name | Scope | Description |
|---|---|---|
summary | { toolCall } | Replaces the summary text in the collapsed header. |
result | { toolCall } | The result surface, for a host to mount its own rendering (a widget, for instance). output is not rendered directly once this is provided. |
icon | { status } | Replaces the status icon. |
Best Practices
- Use the
resultslot for structured output — a table, a chart, a widget — and leaveoutputas the plain-text fallback for when no widget is mounted. - Only offer retry while
statusiserror, and move the status back torunningonceretryarrives, or users will click it repeatedly. - Append to logs line by line rather than replacing the whole block, so the tail-following stays smooth.
- Override all six label props together on non-English surfaces; a partial override produces a mixed-language card.
- Write
summaryas what the call did rather than repeating the tool name — the collapsed row is the only thing users scan.