AI Tool UI Patterns
Overview
When a model calls a tool, most apps dump raw JSON into the conversation. Tool UI (by the assistant-ui project) is an open-source component library where each component turns a specific kind of tool output — a card, table, option list, chart, approval, form, or media card — into real, interactive UI so users can understand and act without leaving the chat. It is JSON-native, typed (Zod schemas), accessible, and built on Tailwind, Radix, and shadcn/ui. Read this when designing how tool-call results render and how users approve or respond to them.
Official sources
Install / setup
npx shadcn@latest add @tool-ui/link-preview
Components use the shadcn copy/paste model — they live in your codebase with no dependency lock-in; swap link-preview for any component name.
Core concepts
- Each component maps one kind of tool output to UI (table, chart, option list, approval, form, media card), instead of showing raw JSON.
- Copy/paste model (like shadcn/ui): components live in your repo, so there is no dependency lock-in.
- Every component ships a colocated
schema.ts Zod schema; tool output is validated, rendered when valid, and fails safely when not.
- A three-part flow: backend tool defines input/output via AI SDK + Zod, the schema validates on server and client, and a frontend
toolkit maps tool names to components.
- Built on Tailwind, Radix, and shadcn/ui, so it inherits accessible primitives and your theme.
Best practices
- Validate tool output against the component's Zod schema on both server and client before rendering.
- Maintain a
toolkit mapping of backend tool names to frontend components so the runtime can pick the right renderer.
- Prefer interactive surfaces (approvals, forms) over read-only JSON dumps for actions the user must take.
- Since components are copied into your repo, version and customize them deliberately rather than expecting upstream updates.
Common pitfalls
- Rendering unvalidated tool JSON → parse against the Zod schema and fail safely when it does not match.
- Hard-coding which component renders a tool → use the
toolkit name→component map so new tools are easy to wire.
- Treating it like an installed npm package → it is copy/paste; you own the code and its updates.
Examples
// Register tools -> components so the runtime knows what to render.
const toolkit = {
getMetrics: MetricsTable,
deployPlan: ApprovalCard,
linkPreview: LinkPreview,
};
Further reading
Related skills
- ../vercel-ai-sdk-elements — AI Elements (includes a Tool component)
- ../ai-attachments-ui — attachment UI patterns
1---2name: ai-tool-ui-patterns3description: UI patterns for AI tool-calls and results — turn tool JSON into typed, validated components; consult when rendering tool outputs in chat.4domain: reference5category: reference6tags: [tool-ui, ai-ui, tool-calling, zod, shadcn, assistant-ui]7official_sources:8 - https://www.tool-ui.com/docs/overview9 - https://github.com/assistant-ui/tool-ui10verified: 2026-06-1611metadata:12 source: https://skillmd.com/skills/gabriel7silva/ai-tool-ui-patterns13---1415# AI Tool UI Patterns1617## Overview18When a model calls a tool, most apps dump raw JSON into the conversation. Tool UI (by the assistant-ui project) is an open-source component library where each component turns a specific kind of tool output — a card, table, option list, chart, approval, form, or media card — into real, interactive UI so users can understand and act without leaving the chat. It is JSON-native, typed (Zod schemas), accessible, and built on Tailwind, Radix, and shadcn/ui. Read this when designing how tool-call results render and how users approve or respond to them.1920## Official sources21- Docs: https://www.tool-ui.com/docs/overview22- Repo: https://github.com/assistant-ui/tool-ui23- Quick start: https://www.tool-ui.com/docs/quick-start2425## Install / setup26```bash27npx shadcn@latest add @tool-ui/link-preview28```29Components use the shadcn copy/paste model — they live in your codebase with no dependency lock-in; swap `link-preview` for any component name.3031## Core concepts32- Each component maps one kind of tool output to UI (table, chart, option list, approval, form, media card), instead of showing raw JSON.33- Copy/paste model (like shadcn/ui): components live in your repo, so there is no dependency lock-in.34- Every component ships a colocated `schema.ts` Zod schema; tool output is validated, rendered when valid, and fails safely when not.35- A three-part flow: backend tool defines input/output via AI SDK + Zod, the schema validates on server and client, and a frontend `toolkit` maps tool names to components.36- Built on Tailwind, Radix, and shadcn/ui, so it inherits accessible primitives and your theme.3738## Best practices39- Validate tool output against the component's Zod schema on both server and client before rendering.40- Maintain a `toolkit` mapping of backend tool names to frontend components so the runtime can pick the right renderer.41- Prefer interactive surfaces (approvals, forms) over read-only JSON dumps for actions the user must take.42- Since components are copied into your repo, version and customize them deliberately rather than expecting upstream updates.4344## Common pitfalls45- Rendering unvalidated tool JSON → parse against the Zod schema and fail safely when it does not match.46- Hard-coding which component renders a tool → use the `toolkit` name→component map so new tools are easy to wire.47- Treating it like an installed npm package → it is copy/paste; you own the code and its updates.4849## Examples50```ts51// Register tools -> components so the runtime knows what to render.52const toolkit = {53 getMetrics: MetricsTable,54 deployPlan: ApprovalCard,55 linkPreview: LinkPreview,56};57```5859## Further reading60- Quick start: https://www.tool-ui.com/docs/quick-start61- assistant-ui project: https://github.com/assistant-ui6263## Related skills64- ../vercel-ai-sdk-elements — AI Elements (includes a Tool component)65- ../ai-attachments-ui — attachment UI patterns