Tool Call Card
SaveShow the status and result of an agent tool call.
- Category
- Agent
- Version
- 0.3.0
- Frameworks
- Next.js, Vite + React, Vite + Vue
- Styling
- Tailwind CSS v4
Preview
fetch_page
Read /docs/api/rate-limits
Input
{
"path": "/docs/api/rate-limits"
}Installation
npx @shakenui/cli add tool-call-cardReview the plan first. A dry run lists every file and package without changing anything:
npx @shakenui/cli add tool-call-card --dry-runUsage
import { ToolCallCard } from "@/components/shaken/agent/tool-call-card";
export default function ToolCallCardExample() {
return (
<div className="grid w-full max-w-md gap-3">
<ToolCallCard
name="search_docs"
status="success"
summary="Search the docs for “rate limits”"
input={{ query: "rate limits", limit: 5 }}
output="Found 3 pages."
durationMs={820}
/>
<ToolCallCard
name="fetch_page"
status="error"
summary="Read /docs/api/rate-limits"
error="The docs server returned 504 Gateway Timeout."
durationMs={1340}
/>
</div>
);
}States
Every state, rendered from local fixture data.
search_docs
Search the docs for “rate limits”
search_docs
Search the docs for “rate limits”
search_docs
Search the docs for “rate limits”
Output
Found 3 pages: /docs/api/rate-limits, /docs/plans, /docs/errors#429
search_docs
Search the docs for “rate limits”
Search index unavailable (503).
API
| Prop | Type | Default | Description |
|---|---|---|---|
| name | string | — | Tool name, shown in monospace. |
| status | "queued" | "running" | "success" | "error" | — | Current state of the call. |
| summary | ReactNode | — | One line describing what the call does. |
| input | unknown | — | Arguments passed to the tool, rendered as formatted JSON. |
| output | ReactNode | — | Result shown on success. Strings render in a soft-wrapping well. |
| error | ReactNode | — | Message shown on failure in a red tinted box, always visible. |
| durationMs | number | — | Elapsed time, shown once the call finishes. |
| defaultOpen | boolean | false | Opens the input and output disclosure initially. |
| activity | "thinking" | "searching" | "working" | "planning" | "listening" | "shaping" | "working" | Which Agent State mark animates while the call runs. |
Accessibility
- The status pill is a live region whose text is exactly Queued, Running, Succeeded, or Failed, so screen readers announce each change.
- Every state has a text label and its own shape (dashed circle, animated dot mark, check, x); color is never the only signal.
- aria-busy is set while running.
- Input and output use native <details>/<summary>, which work with the keyboard out of the box. Height animates only where ::details-content is supported.
- With reduced motion the running mark holds a still frame and the status swap, check draw, and disclosure are instant; the label still changes.
Files
Installed into src/components/shaken, or components/shaken when the project has no src directory.
src/components/shaken/agent/tool-call-card.tsxtool-call-card- Also installs agent-state@0.1.0registry dependency
- npm packages: noneReact and Tailwind CSS v4 required
Source
The exact source the CLI installs, from /r/items/react/tool-call-card/0.3.0.json.
agent/tool-call-card.tsxShowHide
import type { ComponentProps, ReactNode } from "react";
import { type AgentActivity, type AgentPhase, AgentState } from "./agent-state";
export type ToolCallStatus = "queued" | "running" | "success" | "error";
const statuses: Record<ToolCallStatus, { label: string; phase: AgentPhase }> = {
queued: { label: "Queued", phase: "idle" },
running: { label: "Running", phase: "active" },
success: { label: "Succeeded", phase: "done" },
error: { label: "Failed", phase: "failed" },
};
const ease = "ease-[cubic-bezier(0.23,1,0.32,1)]";
export interface ToolCallCardProps extends Omit<ComponentProps<"article">, "children"> {
/** Tool name, for example `search_docs`. */
name: string;
status: ToolCallStatus;
/** One line describing what the call does. */
summary?: ReactNode;
/** Arguments passed to the tool. Rendered as formatted JSON. */
input?: unknown;
/** Result shown when the call succeeds. Strings render as preformatted text. */
output?: ReactNode;
/** Message shown when the call fails. */
error?: ReactNode;
/** Elapsed time, shown once the call finishes. */
durationMs?: number;
/** Opens the input and output details initially. */
defaultOpen?: boolean;
/** Which agent state mark animates while the call runs. Defaults to working. */
activity?: AgentActivity;
}
/** One agent tool call: its status, what it does, how long it took, and its input and output. */
export function ToolCallCard({
name,
status,
summary,
input,
output,
error,
durationMs,
defaultOpen = false,
activity = "working",
className,
...props
}: ToolCallCardProps) {
const meta = statuses[status];
const finished = status === "success" || status === "error";
const showOutput = status === "success" && output != null;
const hasInput = input !== undefined;
const detailsLabel = hasInput && showOutput ? "Input and output" : hasInput ? "Input" : "Output";
return (
<article
data-status={status}
aria-busy={status === "running" || undefined}
className={[
"overflow-hidden rounded-xl border bg-white text-left text-zinc-950 shadow-[0_1px_2px_rgb(0_0_0/0.04)]",
"transition-[border-color] duration-200 motion-reduce:transition-none",
"dark:bg-black dark:text-white dark:shadow-[inset_0_1px_0_rgb(255_255_255/0.06)]",
status === "error" ? "border-red-500/35" : "border-zinc-950/10 dark:border-white/10",
className,
]
.filter(Boolean)
.join(" ")}
{...props}
>
<div className="flex items-start gap-3 p-4">
<div className="min-w-0 flex-1">
<h3
className={[
"truncate font-mono text-[13px] leading-6 font-medium transition-colors duration-200 motion-reduce:transition-none",
status === "queued" ? "text-zinc-500" : "",
].join(" ")}
>
{name}
</h3>
{summary ? (
<p className={`text-sm transition-colors duration-200 motion-reduce:transition-none ${status === "queued" ? "text-zinc-500" : "text-zinc-600 dark:text-zinc-400"}`}>
{summary}
</p>
) : null}
</div>
<div className="flex shrink-0 items-center gap-2.5">
{finished && durationMs != null ? (
<span
key="duration"
className={`font-mono text-xs text-zinc-500 tabular-nums transition-opacity duration-300 ${ease} starting:opacity-0 motion-reduce:transition-none`}
>
{formatDuration(durationMs)}
</span>
) : null}
{/* A live region whose text is exactly the status label; the mark is decorative. */}
<AgentState status size="sm" activity={activity} phase={meta.phase} label={meta.label} />
</div>
</div>
{status === "error" && error != null ? (
<p
key="error"
className={`mx-4 -mt-1 mb-4 rounded-lg border border-red-500/35 bg-red-500/[0.08] px-3 py-2 text-sm text-red-700 transition-[opacity,translate] duration-200 ${ease} starting:-translate-y-1 starting:opacity-0 motion-reduce:transition-none dark:text-red-300`}
>
{error}
</p>
) : null}
{hasInput || showOutput ? (
<details
open={defaultOpen}
className={[
"group border-t border-zinc-950/[0.07] [interpolate-size:allow-keywords] dark:border-white/[0.08]",
// Height animates where ::details-content and interpolate-size are supported; elsewhere it simply opens.
"[&::details-content]:h-0 [&::details-content]:overflow-clip [&::details-content]:transition-[height,content-visibility] [&::details-content]:duration-[220ms] [&::details-content]:ease-[cubic-bezier(0.23,1,0.32,1)] [&::details-content]:[transition-behavior:allow-discrete]",
"open:[&::details-content]:h-auto motion-reduce:[&::details-content]:transition-none",
].join(" ")}
>
<summary
className={[
"flex cursor-pointer list-none items-center justify-between gap-3 px-4 py-2.5 text-xs font-medium select-none [&::-webkit-details-marker]:hidden",
"text-zinc-600 transition-colors duration-150 hover:bg-zinc-950/[0.03] hover:text-zinc-950 motion-reduce:transition-none",
"dark:text-zinc-400 dark:hover:bg-white/[0.04] dark:hover:text-white",
"focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-sky-500",
].join(" ")}
>
{detailsLabel}
<svg
aria-hidden="true"
viewBox="0 0 16 16"
className={`size-4 text-zinc-500 transition-transform duration-200 ${ease} group-open:rotate-180 motion-reduce:transition-none`}
>
<path d="m4.5 6.25 3.5 3.5 3.5-3.5" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
</svg>
</summary>
<div
className={`grid grid-cols-[minmax(0,1fr)] gap-3 px-4 pt-1 pb-4 opacity-0 transition-opacity duration-200 ${ease} group-open:opacity-100 motion-reduce:transition-none`}
>
{/* The summary already names a lone section, so labels only appear when there are two. */}
{hasInput ? <Section label={showOutput ? "Input" : undefined}>{JSON.stringify(input, null, 2)}</Section> : null}
{showOutput ? (
<Section label={hasInput ? "Output" : undefined} wrap>
{output}
</Section>
) : null}
</div>
</details>
) : null}
</article>
);
}
/** A labeled well. `wrap` soft-wraps long lines (tool output); JSON keeps its layout and scrolls. */
function Section({ label, wrap = false, children }: { label?: string; wrap?: boolean; children: ReactNode }) {
return (
<div>
{label ? <p className="mb-1.5 text-xs font-medium text-zinc-500">{label}</p> : null}
{typeof children === "string" ? (
<pre className={`${wrap ? "break-words whitespace-pre-wrap" : "overflow-x-auto"} rounded-lg border border-zinc-950/[0.07] bg-zinc-950/[0.02] px-3 py-2.5 font-mono text-xs leading-relaxed text-zinc-800 dark:border-white/[0.08] dark:bg-transparent dark:text-zinc-300`}>
{children}
</pre>
) : (
<div className="text-sm">{children}</div>
)}
</div>
);
}
function formatDuration(ms: number): string {
return ms < 1000 ? `${Math.round(ms)} ms` : `${(ms / 1000).toFixed(1)} s`;
}Vue
A native Vue 3 implementation ships in the Vue pilot. Run the same command in a Vite + Vue project; the CLI detects Vue and installs these files instead. The live preview above is the React version; the Vue example below is built in a clean Vite + Vue app by CI.
<script setup lang="ts">
import ToolCallCard from "@/components/shaken/agent/ToolCallCard.vue";
</script>
<template>
<div class="grid w-full max-w-md gap-3">
<ToolCallCard
name="search_docs"
status="success"
summary="Search the docs for “rate limits”"
:input="{ query: 'rate limits', limit: 5 }"
output="Found 3 pages."
:duration-ms="820"
/>
<ToolCallCard name="fetch_page" status="error" summary="Read /docs/api/rate-limits" error="The docs server returned 504 Gateway Timeout." :duration-ms="1340" />
</div>
</template>src/components/shaken/agent/ToolCallCard.vuevue/tool-call-card@0.3.0
agent/ToolCallCard.vueShowHide
<script lang="ts">
export type ToolCallStatus = "queued" | "running" | "success" | "error";
</script>
<script setup lang="ts">
import { computed } from "vue";
import AgentState from "./AgentState.vue";
import type { AgentActivity, AgentPhase } from "./agent-marks";
/** One agent tool call: its status, what it does, how long it took, and its input and output. */
const props = withDefaults(
defineProps<{
/** Tool name, for example `search_docs`. */
name: string;
status: ToolCallStatus;
/** One line describing what the call does. */
summary?: string;
/** Arguments passed to the tool. Rendered as formatted JSON. */
input?: unknown;
/** Result shown when the call succeeds. */
output?: string;
/** Message shown when the call fails. */
error?: string;
/** Elapsed time, shown once the call finishes. */
durationMs?: number;
/** Opens the input and output details initially. */
defaultOpen?: boolean;
/** Which agent state mark animates while the call runs. */
activity?: AgentActivity;
}>(),
{ defaultOpen: false, activity: "working" },
);
const statuses: Record<ToolCallStatus, { label: string; phase: AgentPhase }> = {
queued: { label: "Queued", phase: "idle" },
running: { label: "Running", phase: "active" },
success: { label: "Succeeded", phase: "done" },
error: { label: "Failed", phase: "failed" },
};
const ease = "ease-[cubic-bezier(0.23,1,0.32,1)]";
const meta = computed(() => statuses[props.status]);
const finished = computed(() => props.status === "success" || props.status === "error");
const showOutput = computed(() => props.status === "success" && props.output != null);
const hasInput = computed(() => props.input !== undefined);
const detailsLabel = computed(() => (hasInput.value && showOutput.value ? "Input and output" : hasInput.value ? "Input" : "Output"));
const duration = computed(() =>
props.durationMs == null ? "" : props.durationMs < 1000 ? `${Math.round(props.durationMs)} ms` : `${(props.durationMs / 1000).toFixed(1)} s`,
);
const well =
"rounded-lg border border-zinc-950/[0.07] bg-zinc-950/[0.02] px-3 py-2.5 font-mono text-xs leading-relaxed text-zinc-800 dark:border-white/[0.08] dark:bg-transparent dark:text-zinc-300";
</script>
<template>
<article
:data-status="props.status"
:aria-busy="props.status === 'running' || undefined"
:class="[
'overflow-hidden rounded-xl border bg-white text-left text-zinc-950 shadow-[0_1px_2px_rgb(0_0_0/0.04)]',
'transition-[border-color] duration-200 motion-reduce:transition-none',
'dark:bg-black dark:text-white dark:shadow-[inset_0_1px_0_rgb(255_255_255/0.06)]',
props.status === 'error' ? 'border-red-500/35' : 'border-zinc-950/10 dark:border-white/10',
]"
>
<div class="flex items-start gap-3 p-4">
<div class="min-w-0 flex-1">
<h3
:class="[
'truncate font-mono text-[13px] leading-6 font-medium transition-colors duration-200 motion-reduce:transition-none',
props.status === 'queued' ? 'text-zinc-500' : '',
]"
>
{{ props.name }}
</h3>
<p
v-if="props.summary"
:class="[
'text-sm transition-colors duration-200 motion-reduce:transition-none',
props.status === 'queued' ? 'text-zinc-500' : 'text-zinc-600 dark:text-zinc-400',
]"
>
{{ props.summary }}
</p>
</div>
<div class="flex shrink-0 items-center gap-2.5">
<span
v-if="finished && duration"
key="duration"
:class="`font-mono text-xs text-zinc-500 tabular-nums transition-opacity duration-300 ${ease} starting:opacity-0 motion-reduce:transition-none`"
>{{ duration }}</span
>
<!-- A live region whose text is exactly the status label; the mark is decorative. -->
<AgentState status size="sm" :activity="props.activity" :phase="meta.phase" :label="meta.label" />
</div>
</div>
<p
v-if="props.status === 'error' && props.error"
:class="`mx-4 -mt-1 mb-4 rounded-lg border border-red-500/35 bg-red-500/[0.08] px-3 py-2 text-sm text-red-700 transition-[opacity,translate] duration-200 ${ease} starting:-translate-y-1 starting:opacity-0 motion-reduce:transition-none dark:text-red-300`"
>
{{ props.error }}
</p>
<details
v-if="hasInput || showOutput"
:open="props.defaultOpen"
:class="[
'group border-t border-zinc-950/[0.07] [interpolate-size:allow-keywords] dark:border-white/[0.08]',
// Height animates where ::details-content and interpolate-size are supported; elsewhere it simply opens.
'[&::details-content]:h-0 [&::details-content]:overflow-clip [&::details-content]:transition-[height,content-visibility] [&::details-content]:duration-[220ms] [&::details-content]:ease-[cubic-bezier(0.23,1,0.32,1)] [&::details-content]:[transition-behavior:allow-discrete]',
'open:[&::details-content]:h-auto motion-reduce:[&::details-content]:transition-none',
]"
>
<summary
class="flex cursor-pointer list-none items-center justify-between gap-3 px-4 py-2.5 text-xs font-medium text-zinc-600 transition-colors duration-150 select-none hover:bg-zinc-950/[0.03] hover:text-zinc-950 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-sky-500 motion-reduce:transition-none dark:text-zinc-400 dark:hover:bg-white/[0.04] dark:hover:text-white [&::-webkit-details-marker]:hidden"
>
{{ detailsLabel }}
<svg
aria-hidden="true"
viewBox="0 0 16 16"
:class="`size-4 text-zinc-500 transition-transform duration-200 ${ease} group-open:rotate-180 motion-reduce:transition-none`"
>
<path d="m4.5 6.25 3.5 3.5 3.5-3.5" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" />
</svg>
</summary>
<div
:class="`grid grid-cols-[minmax(0,1fr)] gap-3 px-4 pt-1 pb-4 opacity-0 transition-opacity duration-200 ${ease} group-open:opacity-100 motion-reduce:transition-none`"
>
<!-- The summary already names a lone section, so labels only appear when there are two. -->
<div v-if="hasInput">
<p v-if="showOutput" class="mb-1.5 text-xs font-medium text-zinc-500">Input</p>
<pre :class="['overflow-x-auto', well]">{{ JSON.stringify(props.input, null, 2) }}</pre>
</div>
<div v-if="showOutput">
<p v-if="hasInput" class="mb-1.5 text-xs font-medium text-zinc-500">Output</p>
<pre :class="['break-words whitespace-pre-wrap', well]">{{ props.output }}</pre>
</div>
</div>
</details>
</article>
</template>