Components/Tool Call Card

Tool Call Card

A status card for a single tool call.

VerifiedSince 0.3.9

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 result slot and keep output as the plain-text fallback.
  • On retry, set status back to running right 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 all six label props together to avoid a mixed-language card.
  • Write summary as what the call did, not the tool name again; the collapsed row is all users scan.

API Reference

Props

NameTypeDefaultDescription
toolCallAiToolCallPart—The call to render. Required.
defaultExpandedbooleanfalseInitial expanded state; read once, on mount.
retryLabelstring'Retry'Label of the retry button.
pendingLabelstring'Queued'Label for pending.
runningLabelstring'Running'Label for running.
doneLabelstring'Done'Label for done and any unmatched status.
errorLabelstring'Failed'Label for error.
inputLabelstring'Input'Heading of the input section.

AiToolCallPart is { type, id, name, status, summary?, input?, output?, error?, logs? }, where status is 'pending' | 'running' | 'done' | 'error'.

Events

NamePayloadDescription
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

NameScopeDescription
summary{ toolCall }Replaces the summary in the collapsed header.
result{ toolCall }Result surface for the host's own rendering; replaces output when provided.
icon{ status }Replaces the status icon.

Overview

  • The body follows status: running shows logs, done shows the result slot (falling back to output), and error shows error with a retry button; input shows whenever it is set.
  • Every change to logs scrolls the log region to the bottom.
  • status is mirrored onto the root's data-status for styling.

Technologies

  • AiToolCallPart is defined and exported by ai-elements.
  • Source: packages/tuffex/packages/components/src/tool-call-card/.