Collapsible tool-call cards for inputs, outputs, errors, approvals, and grouped tool activity.
Use ChatTool to show tool calls emitted by an agent or assistant.
ChatTool is a subpath-only import (@heroui-pro/react/chat-tool) because it renders a CodeBlock and depends on the optional shiki peer. It is not exported from the package root, so SSR apps that don't use it never need shiki installed.
import {ChatTool, ChatToolGroup} from "@heroui-pro/react/chat-tool";
<ChatTool state="output-available" toolName="searchDocs">
<ChatTool.Trigger>
<ChatTool.StatusIcon />
{/* ... */}
</ChatTool.Trigger>
<ChatTool.Content>
<ChatTool.Args input={input} label="Input" />
<ChatTool.Result label="Result" value={output} />
<ChatTool.Error errorText={errorText} /> {/* Optional */}
<ChatTool.Approval>{/* ... */}</ChatTool.Approval> {/* Optional */}
</ChatTool.Content>
</ChatTool>;
<ChatToolGroup>
<ChatToolGroup.Trigger>{/* ... */}</ChatToolGroup.Trigger>
<ChatToolGroup.Content>{/* ... */}</ChatToolGroup.Content>
</ChatToolGroup>;Use ChatToolGroup to group consecutive tool calls.
Use streaming state while tool input is still being generated.
Use error state for failed tool calls.
Use approval state when a tool requires user confirmation.
Tool cards expose slots for custom trigger and content layouts.
HeroUI follows the BEM methodology to ensure component variants and states are reusable and easy to customize.
The Chat Tool component uses these CSS classes:
.chat-tool: Tool card root.chat-tool--streaming / .chat-tool--running / .chat-tool--complete / .chat-tool--error / .chat-tool--requires-action: State modifiers, from state.chat-tool__trigger: Collapsible trigger.chat-tool__trigger-label: Trigger label, shimmering while running.chat-tool__trigger-name: Tool name in the trigger label, from toolName.chat-tool__indicator: Trigger chevron, rendered when expandable.chat-tool__status: Default status icon wrapper.chat-tool__status-icon: Status icon, default or custom.chat-tool__status-icon--complete / .chat-tool__status-icon--error / .chat-tool__status-icon--requires-action: Status icon colors, from state.chat-tool__content: Disclosure content panel.chat-tool__content-body: Content padding.chat-tool__args: Tool input content.chat-tool__result: Tool output content.chat-tool__error: Tool error content.chat-tool__args-label / .chat-tool__result-label / .chat-tool__error-label: Section labels, rendered when label is set.chat-tool__approval: Approval section, requires-action only.chat-tool__approval-actions: Approve and reject buttons.chat-tool__meta: Tool call id.chat-tool-group: Grouped tool root.chat-tool-group__trigger / .chat-tool-group__trigger-label / .chat-tool-group__indicator: Group trigger, its label, and chevron.chat-tool-group__content / .chat-tool-group__content-body: Group panel and its padding| Prop | Type | Default | Description |
|---|---|---|---|
toolName | string | - | Tool display name |
state | 'input-streaming' | 'input-available' | 'output-available' | 'output-error' | 'requires-action' | - | Tool state |
triggerPrefix | ReactNode | - | Optional label rendered before toolName in preset mode |
input | unknown | - | Tool input rendered as JSON in preset mode |
output | unknown | - | Tool output rendered as JSON in preset mode |
argsText | string | - | Preformatted tool input text, useful while streaming partial JSON |
errorText | string | - | Error details rendered for output-error state |
onApprove | () => void | - | Called by the preset approval action in requires-action state |
onReject | () => void | - | Called by the preset rejection action in requires-action state |
defaultExpanded | boolean | - | Open by default |
isExpanded | boolean | - | Controlled expanded state |
Renders the collapsible tool trigger.
Renders the expanded tool body.
Semantic slots for tool input, output, error details, and approval controls.
Groups multiple ChatTool items. Extends HeroUI Disclosure props.
Resources