Chat Tool
ProOne tool call in a chat: its name, a spinner, check, failure or cancel mark, and the input and result behind the row.
Playground
- Input
- query: "Q3 revenue", scope: "project"
- Result
- 12 matches in 4 files
- Input
- query: "Q3 revenue", scope: "project"
- Result
- 12 matches in 4 files
- Input
- query: "Q3 revenue", scope: "project"
- Result
- 12 matches in 4 files
- Input
- query: "Q3 revenue", scope: "project"
- Result
- 12 matches in 4 files
- Input
- query: "Q3 revenue", scope: "project"
- Result
- 12 matches in 4 files
Installation
Chat Tool comes with WunderUI Core and Pro, in the package from your plan. See the plans.
Then import what you need:
import { ChatTool, ChatToolStatus } from "@wunderui/react"Then use it:
import { ChatTool } from "@wunderui/react"
export function Call({ status }: { status: "running" | "done" | "error" | "cancelled" }) {
return (
<ChatTool name="Search documents" status={status} duration="1.2 s" error="The request timed out after 30 s">
12 matches in 4 files
</ChatTool>
)
}Expected result: You see a card with a wrench, the name Search documents, 1.2 s, a green check and a chevron. Press it to open the result, and set the status to error to turn it red with the reason.
When to use
Use Chat Tool for
- A tool or function call an assistant makes inside a message
- A call that takes a moment, so the reader sees it running and then done, failed or cancelled
- Input, result and duration of a call behind a disclosure
Use something else for
- Chat Loader for the dots while the assistant has not started its answer
- Run Timeline for a whole run with many steps, tools and results
- Alert for an error that is about the whole page or request, not one tool call
Details
The details behind the row show the input, the result and how long the call took. Keep them short, and without details the row has no chevron and cannot open.
- Input
- query: "Q3 revenue", scope: "project"
- Input
- query: "Q3 revenue", scope: "project"
- Result
- 12 matches in 4 files
- Input
- query: "Q3 revenue", scope: "project"
- Result
- 12 matches in 4 files
- Duration
- 1.2 s
Result
A finished call can show its duration before the status mark. A failed call turns the card red and shows the reason under the name, and a cancelled call is muted.
- Input
- query: "Q3 revenue", scope: "project"
- Result
- 12 matches in 4 files
- Duration
- 1.2 s
- Input
- query: "Q3 revenue", scope: "project"
- Result
- 12 matches in 4 files
- Duration
- 1.2 s
Name
The name is the label of the row. Say what the call does for the person, keep the function name for the details, and a long name wraps.
- Input
- query: "Q3 revenue", scope: "project"
- Result
- 12 matches in 4 files
- Input
- query: "Q3 revenue", scope: "project"
- Result
- 12 matches in 4 files
- Input
- query: "Q3 revenue", scope: "project"
- Result
- 12 matches in 4 files
Newer props
A tool call can carry a muted detail, a status badge, meta such as the token count, and labelled input and output in the expanded body. mono sets the name in monospace.
Detail, badge, meta, input and output
{ "nodeId": "312:44" }{
"name": "Checkout",Keyboard interactions
The header is a native button, so the browser handles focus and activation. A tool without content has no disclosure and does nothing on a press.
- TaborShift+Tab
- Moves focus to the header button, and, when the details are open, on to the buttons and links inside them. Focus shows as an indigo border with a 2 px ring.
- EnterorSpace
- Opens or closes the details of the focused tool. follows.
Behavior and motion
What the card does with its details, its status, assistive technology and motion.
- Disclosure
- With content, the header is a disclosure button that reports whether it is expanded, and the card starts closed with no prop to open it. Without content there is no chevron.
- Details
- The details stay mounted and are inert while closed, so nothing inside takes focus or is read out. They grow and shrink with the same height transition the Collapsible uses.
- Status
- Running shows a turning loader, done a check, error a warning triangle on a red card, cancelled a muted ban. The word is hidden text in the button, and a change is not announced.
- Duration
- The duration is shown as given, before the status mark, in tabular numbers so a changing value does not shift the row. Format it yourself, for example 1.2 s.
- Live region
- Add a status line next to the card, mounted before it has text, saying the tool is running, then how long it took or why it failed. In a chat log, keep it marked busy while the reply streams.
- Failure and cancel
- Error turns the card red and shows the error text under the name, and cancelled keeps it neutral. Neither has a retry control, so add a Button and set the status back to running.
- States
- Focus is an indigo border with a 2 px ring on the header. The header has no hover fill.
- Motion
- The loader turns, the details open with a smooth height change, and the chevron turns quickly.
- Reduced motion
- With reduced motion the loader stands still, the details open and close at once and the chevron turns at once. The status and its text stay as before.
Anatomy
The figure marks the card with its details open. The duration is optional and the hidden status text has no box on screen, so neither has a number.
- Input
- query: "Q3 revenue", scope: "project"
- Result
- 12 matches in 4 files
- 1data-slot="chat-tool"
A card with a 1 px border and a 16 px radius. The header is one full-width button with the details under it, and a failed call turns the border and fill red.
- 2
A 14 px wrench in the tertiary text colour.
- 3
The name in 12 px medium text. It takes the free width and wraps when long, and a failed call shows its error text in a second line under it.
- 4
A 14 px mark: a turning loader while running, a green check when done, a warning triangle on error, a muted ban when cancelled. The turning stops under reduced motion.
- 5Optional
A 14 px chevron that turns when the details are open. It is drawn only when the tool has content.
- 6Optional
The content of the card, in a 16 px padded area under a 1 px divider. Closed details are inert, so they take no focus and are not read out.
- Optional
The duration in 12 px tabular numbers, before the status mark. It is drawn only when you pass it.
The word Running, Done, Failed or Cancelled inside the header button, visible only to assistive technology. It is part of the button's name.
Best practices
- Do
Pass the input, the result and the duration as content, in rows, to make the card open. Keep them short and as text.
- Do
Set the status to running while the call is in flight, then done, error or cancelled. Screen readers hear it in the button's name, and the spinner stops under reduced motion.
- Do
Say the change in a status line next to the card that is in the page before it has text. The button's name changes, but a changed name is not announced.
- Do
Name the call for the person, like Search documents, and keep the function name and its arguments in the details.
- Do
For a failed call, pass the reason as the error in one short sentence a person can act on, and put a Retry button next to the card.
- Don’t
Don't put a long stack trace into the error. It is one line under the name, so keep the full message in the details.
- Don’t
Don't put anything the reader needs into the details while the card is closed. Closed details are inert, so their buttons cannot be reached.
API reference
ChatTool is a plain component, so this table lists every prop.
A card with a 1 px border and a 16 px radius. The header is one full-width button with the details under it, and a failed call turns the border and fill red.
| Prop | Type | Default | Description |
|---|---|---|---|
| name required | string | — | The label of the call, one row of text that wraps when it is long. Also part of the button's name. |
| status | "error" | "cancelled" | "running" | "done" | "done" | shows the turning loader, (default) the green check, a warning triangle on a red card and a muted ban. The word for each is hidden text in the button. |
| duration | string | — | How long the call took, for example . Shown as given before the status mark, in any status. |
| error | string | — | Why the call failed, one short sentence under the name. Shown only when is . |
| children | ReactNode | — | The details behind the row: input, result, duration. With children the card has a chevron and opens; without them it does neither. |
| className | string | — | Extra classes for the card, for example or a margin. |
| badge | ReactNode | — | Status pill rendered after the name, replacing the status icon. |
| defaultOpen | boolean | false | Whether the body starts open. |
| detail | ReactNode | — | Muted detail shown next to the name in the header. |
| input | ReactNode | — | Labelled input block shown at the top of the expanded body. |
| meta | ReactNode | — | Small text rendered after the duration. |
| mono | boolean | false | Renders the name in monospace at a slightly larger size. |
| output | ReactNode | — | Labelled output block shown after the input in the expanded body. |
Notes for AI
Give your coding assistant the Markdown reference instead of screenshots.
get_component("chat-tool")The full library index for assistants is at /llms.txt.
Related components
- Done420 tok$0.01640ms
Input
status: overdue, age: 30+ daysOutput
14 invoices, $42,860 in total - Done3,420 tok$0.042.1s
Input
14 invoice idsOutput
14 contacts, all with an email address - Running2,310 tok
Input
template: invoice-overdue-30 - Pending
Input
to: 14 recipients - PendingLog the result
AI & Agents5 stylesProRun TimelineEvery step of a run in order, with duration, tokens and expandable input/output.