Skip to content

    ToolCall

    Compact, expandable step for tool and function invocations in chat and agent streams. Shows a status mark, a human summary, an optional identifier and duration, and expands to reveal `input`, `output` or custom details.

    Preview

    Input
    {"query": "color-accent"}
    Output
    Found 4 matching results.

    Props

    • tool
    • status
    • duration
    • title
    • details
    import { ToolCall } from "@/components/ui/tool-call"
    
    <ToolCall tool="search_docs" duration="420ms" title="Search documentation" input="{\"query\": \"color-accent\"}" output="Found 4 matching results." defaultOpen className="max-w-md" />

    Usage

    When to use

    • Display individual tool or function invocations in an assistant stream with status, duration and expandable details.
    • Let readers inspect raw arguments and outputs on demand without cluttering the conversation.

    When not to use

    • General chronological events such as an order history or activity feed. Use Timeline.
    • Standalone syntax-highlighted code with a copy button. Use CodeBlock.
    • General page FAQ sections or form disclosures. Use Accordion.

    Variants

    status

    Invocation state: `running` shows a small Spinner, `success` shows a check, `error` shows a warning triangle.

    • Input
      {"query": "color-accent"}
      Output
      Found 4 matching results.

      running

    • Input
      {"query": "color-accent"}
      Output
      Found 4 matching results.

      successdefault

    • Input
      {"query": "color-accent"}
      Output
      Request timed out

      error

    import { ToolCall } from "@/components/ui/tool-call"
    
    <ToolCall tool="search_docs" status="running" duration="420ms" title="Search documentation" input="{\"query\": \"color-accent\"}" output="Found 4 matching results." defaultOpen className="max-w-md" />
    <ToolCall tool="search_docs" duration="420ms" title="Search documentation" input="{\"query\": \"color-accent\"}" output="Found 4 matching results." defaultOpen className="max-w-md" />
    <ToolCall tool="search_docs" status="error" duration="420ms" title="Search documentation" input="{\"query\": \"color-accent\"}" output="Request timed out" defaultOpen className="max-w-md" />

    Examples

    Expanded tool call

    Completed step opened by default to inspect its input query and output summary.

    Input
    query: color-accent
    Output
    Found 4 matching pages.
    import { ToolCall } from "@/components/ui/tool-call"
    
    <ToolCall defaultOpen status="success" title="Search documentation" tool="search_docs" duration="420ms" input="query: color-accent" output="Found 4 matching pages." className="max-w-md" />

    Running and failed steps

    Active invocation without details stays static while a failed step expands to show the error output.

    RunningIndexing filesindex_workspace
    Input
    https://werewolf-ui.dev/releases
    Output
    Request timed out after 1800ms
    import { ToolCall } from "@/components/ui/tool-call"
    
    <div className="flex w-full max-w-md flex-col gap-sm">
      <ToolCall status="running" title="Indexing files" tool="index_workspace" />
      <ToolCall defaultOpen status="error" title="Fetch release notes" tool="fetch_url" duration="1.8s" input="https://werewolf-ui.dev/releases" output="Request timed out after 1800ms" />
    </div>

    Static step

    Without input, output or children, no chevron or disclosure button is rendered.

    CompletedRead tokens.cssread_file18ms
    import { ToolCall } from "@/components/ui/tool-call"
    
    <ToolCall status="success" title="Read tokens.css" tool="read_file" duration="18ms" className="max-w-md" />

    Do and don't

    Do

    • Write a plain human summary in title and keep the raw function name in tool.
    • Omit input, output and children when there is nothing to inspect so the row stays static.
    • Translate labels when the interface is not in English.

    Don't

    • Do not nest ToolCall inside a raised Card; its sunken surface sits cleanly on the page or in a message stream.
    • Do not leave a step in running status after the stream stops.

    Props

    NameTypeValuesDefaultDescription
    title requirednode--Human-readable summary of the step, such as Search documentation.
    toolstring--Optional technical or function identifier shown in monospace tertiary text, such as `search_docs`.
    statusenumrunning | success | errorsuccessInvocation state: `running` shows a small Spinner, `success` shows a check, `error` shows a warning triangle.
    durationstring--Optional formatted elapsed time shown at the trailing edge, such as `420ms`.
    inputnode--Optional arguments or query payload shown inside the expanded panel.
    outputnode--Optional result or error message shown inside the expanded panel.
    childrennode--Optional custom detail body rendered inside the expanded panel.
    openboolean--Controlled open state. Pair with `onOpenChange`.
    defaultOpenboolean-falseInitial open state when uncontrolled.
    onOpenChange(open: boolean) => void--Called with the next open state when the user toggles the header.
    labels{ input?: string; output?: string; running?: string; success?: string; error?: string }--Section and screen-reader status labels. Defaults: `Input`, `Output`, `Running`, `Completed`, `Failed`.

    Slots

    NameRequiredDescription
    titleyesHuman-readable summary of the tool invocation.
    inputnoOptional arguments or query payload.
    outputnoOptional result or error message.
    childrennoOptional custom detail content.

    Anatomy

    PartDescription
    rootThe outer container: sunken fill, border and container corners, without drop shadows.
    headerSummary row holding the status mark, title, optional tool name, duration and chevron. A button when expandable, static otherwise.
    hitAreaTransparent ::before centered on the header button, at least `size-target-min` (24px on mouse, 44px on touch).
    statusStatus mark at the start: a small Spinner while running, a check in `color-text-success` on success, a warning triangle in `color-text-danger` on error.
    titleHuman-readable summary in medium primary text.
    toolOptional function identifier in monospace tertiary text.
    durationOptional elapsed time at the trailing edge in monospace tertiary text with tabular digits.
    chevronTurning 16px right chevron shown when the step can expand.
    contentCollapsible panel below the header that opens with `duration-medium` and `ease-enter` and exits with `animate-exit-collapse`.
    bodyInner wrapper carrying the top divider and `spacing-md` padding so the collapsing container shrinks cleanly to zero.
    labelSection label (`Input`, `Output`) in small medium secondary text.
    payloadMonospace block on page fill with inner corners for arguments or output; switches to danger tokens on error.

    Accessibility

    Role: generic

    KeysAction
    TabMoves focus to the header button when `input`, `output` or `children` are present, then to any controls inside the expanded panel.
    Enter, SpaceOn the header button, expands or collapses the detail panel.
    • When `input`, `output` or `children` is omitted, the header renders as static text without a button or chevron.
    • Status icons are hidden from screen readers (`aria-hidden`) and paired with visually hidden status words (`Running`, `Completed`, `Failed`), customizable via `labels`.

    Install

    npx werewolf-ui add https://www.werewolf-ui.dev/r/tool-call.json

    Run npx werewolf-ui init once in your app before adding components. Init sets up tokens, their CSS import and agent rules. Add installs this component and its dependencies while preserving your theme. See Installation for requirements and the alternative registry setup.