Keyframery

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.

Resize preview. Focus the handle and use the left or right arrow keys. Hold Shift for larger steps.— px
Customize1 controls
Animation speed1×

Installation

npx shadcn@latest add @keyframery/tool-call

This 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

MoveWhat you see
RiseThe card rises in when it arrives (flourish).
SpinA running call's mark turns and its title has a light passing through it; both say "working" and run at any flourish.
DrawWhen the call finishes, the tick pops in and draws itself (flourish); a failed or denied mark pops in.
FadeA new status label fades in; it rises into place with flourish.
HeightThe body opens to its real height and the chevron turns.
CascadeInput 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.

VariableWhat it changesDefault
--tool-call-faceCard surfacebg-card
--tool-call-inkTitle texttext-foreground
--tool-call-mutedName, time and labelstext-muted-foreground
--tool-call-successDone tickoklch(0.62 0.16 150)
--tool-call-errorFailed calltext-destructive
--tool-call-radiusCard cornersrounded-[12px]
--tool-call-fontTitle sizetext-[13px]
--tool-call-code-heightTallest input or output before it scrollsmax-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>
  • ToolCallName
  • ToolCallStatusText: a <span>
  • ToolCallTitle: a <span>
  • ToolCallValue: a <div>

Hooks

useToolCall

Call it inside the component to read and change its state.

Prop

Type

Keyboard

KeyWhat it does
TabMoves to the card's header.
Enter or SpaceOpens 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.

All components

On this page