Tool Call
One agent tool call as a card: the status mark, a title, the tool's name and the time it took, with the input and the output (or the error) in a body that opens. A failed call opens on its own. Agents read the name, status and summaries of the input and output, and open the card through its collapsible.
See it as an AI agent does.See this component the way an AI agent does.
Installation
npx shadcn@latest add @keyframery/tool-callThis adds components/keyframery/tool-call.tsx and its primitive to your project, and installs UI SDK, along with collapsible, badge, code-block, which it builds on. The motion tokens are added to your global CSS the first time you install a component.
Usage
import { ToolCall } from "@/components/keyframery/tool-call"
export default function Usage() {
return (
<ToolCall
name="find_order"
title="Looked up order #1048"
status="done"
input={{ order_id: "1048" }}
output={{ status: "shipped", carrier: "Royal Mail" }}
duration={420}
/>
)
}Examples
Status
status is "pending", "running", "approval", "done", "error" or "denied". The mark follows it: a dashed ring, a spinner, a pause, a tick that draws itself, a mark, a slash. Pass startedAt and a running call counts up.
A call that fails
With status="error" the card opens on its own and shows error in place of the output. openOnError={false} keeps it closed; onOpenChange hears details.reason === "status-error".
Your own card
Pass parts as children to lay the card out yourself. The trigger is the body's collapsible: an agent opens the card with its setOpen, and the tool call reads the name, status, input and output to it.
Motion
| Move | What you see |
|---|---|
| Rise | The card rises in when it arrives (flourish). |
| Spin | A running call's mark turns and its title has a light passing through it; both say "working" and run at any flourish. |
| Draw | When the call finishes, the tick pops in and draws itself (flourish); a failed or denied mark pops in. |
| Fade | A new status label fades in; it rises into place with flourish. |
| Height | The body opens to its real height and the chevron turns. |
| Cascade | Input and output rise in one after the other as the body opens (flourish). |
Timing and springiness follow the motion style you set. To change how fast this tool call moves, pass speed:
<ToolCall speed="fast">
…
</ToolCall>"fast" is 0.6×, "slow" 1.4×, and a number sets the multiplier. With reduced motion turned on, nothing moves: changes happen at once or with a short fade.
Theming
Set these CSS variables on the component or a parent. Leave them unset to follow the light and dark theme. The open Customize panel below the preview lets you try these settings.
| Variable | What it changes | Default |
|---|---|---|
--tool-call-face | Card surface | bg-card |
--tool-call-ink | Title text | text-foreground |
--tool-call-muted | Name, time and labels | text-muted-foreground |
--tool-call-success | Done tick | oklch(0.62 0.16 150) |
--tool-call-error | Failed call | text-destructive |
--tool-call-radius | Card corners | rounded-[12px] |
--tool-call-font | Title size | text-[13px] |
--tool-call-code-height | Tallest input or output before it scrolls | max-h-[220px] |
API reference
Every part takes className and children, along with the props of the element it renders. The parts are rendered by UI SDK, so they also take render, to draw your own element, and a function of their state for className and style.
ToolCall
Renders a <div>, and takes its props too.
Prop
Type
ToolCallContent
Renders a <div>, and takes its props too.
Prop
Type
ToolCallSection
Renders a <div>, and takes its props too.
Prop
Type
Other parts
These take the props of the element they render, and nothing else:
ToolCallDuration: a<span>ToolCallError: a<p>ToolCallTrigger: a<button>ToolCallIcon: a<span>ToolCallLabel: a<div>ToolCallNameToolCallStatusText: a<span>ToolCallTitle: a<span>ToolCallValue: a<div>
Hooks
useToolCall
Call it inside the component to read and change its state.
Prop
Type
Keyboard
| Key | What it does |
|---|---|
| Tab | Moves to the card's header. |
| Enter or Space | Opens or closes the card. |
Accessibility
Roles, keyboard and focus are declared on the component's UI SDK primitive, and state is announced through the matching ARIA attributes. More in Accessibility.
Built on UI SDK's core
UI SDK doesn't ship a tool call, so this one is defined with its core: one definePrimitive in components/keyframery/core/tool-call-core.ts, with no React in it. UI SDK's adapters can render that same definition in Vue, Svelte, Solid and web components. To keep your own styling and take only the motion, import from @/components/keyframery/primitives/tool-call.
Questions
How does the animated Tool Call for UI SDK move?
Rise: The card rises in when it arrives (flourish). Spin: A running call's mark turns and its title has a light passing through it; both say "working" and run at any flourish. Draw: When the call finishes, the tick pops in and draws itself (flourish); a failed or denied mark pops in. Fade: A new status label fades in; it rises into place with flourish. Height: The body opens to its real height and the chevron turns. Cascade: Input and output rise in one after the other as the body opens (flourish).
Do I need Motion or Framer Motion for the animated Tool Call?
No. Every move is plain CSS, so there is nothing to install besides the component and UI SDK.
UI SDK has no tool call. How is this one built on UI SDK?
Its behaviour is one definition written with UI SDK's core (definePrimitive), in components/keyframery/core/tool-call-core.ts. Its parts are rendered by UI SDK's adapter, so they take render, state-based class names and data-slot, like every UI SDK component.
What happens to the Tool Call when someone turns on reduced motion?
Nothing moves. State changes happen at once, or with a short fade.
More in AI
All componentsReasoning
The thinking behind an AI answer, behind a disclosure: "Thinking…" has a light passing through it while the model works, the thinking opens on its own and closes into "Thought for 12s" when it ends, and it streams in as muted markdown.
Trace
Steps rise in one after another, a running title has a light passing through it, a finished step's tick pops in and draws itself, and a row opens to its real height with its detail cascading in.