Get Started
Components
- Alert
- Avatar
- Badge
- Breadcrumb
- Button
- Button Group
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Checkbox Group
- ComboBox
- Command
- Data Table
- Date Field
- Date Picker
- Date Range Picker
- Dialog
- Disclosure
- Disclosure Group
- Drawer
- Empty
- Field
- File Trigger
- Form
- Grid List
- Hover Card
- Input
- Input Group
- Input OTP
- Item
- Kbd
- Label
- ListBox
- Menu
- Number Field
- Pagination
- Popover
- Progress Bar
- Radio Group
- Range Calendar
- Resizable
- Search Field
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Spinner
- Switch
- Table
- Tabs
- Tag Group
- Text Field
- Textarea
- Time Field
- Toast
- Toggle Button
- Toggle Button Group
- Tooltip
- Tree
- Typography
AI Elements
Parameters
{ "query": "latest AI developments", "maxResults": 5}Result
{ "results": [ { "title": "New AI Model Released", "url": "https://example.com/ai-news", "snippet": "A groundbreaking AI model was announced today..." } ]}import {
Tool,
ToolContent,
ToolHeader,
ToolInput,
ToolOutput,
} from "@/components/ai-elements/tool"
export function ToolDemo() {
const toolData = {
type: "tool-search-web",
state: "output-available" as const,
input: {
query: "latest AI developments",
maxResults: 5,
},
output: {
results: [
{
title: "New AI Model Released",
url: "https://example.com/ai-news",
snippet: "A groundbreaking AI model was announced today...",
},
],
},
errorText: undefined,
}
return (
<Tool defaultOpen>
<ToolHeader
title="Search Web"
type={toolData.type}
state={toolData.state}
/>
<ToolContent>
<ToolInput input={toolData.input} />
<ToolOutput output={toolData.output} errorText={toolData.errorText} />
</ToolContent>
</Tool>
)
}
Installation
CLI
Manual
pnpmnpmyarnbunpnpm dlx shadcn@latest add tool
Usage
import {
Tool,
ToolHeader,
ToolContent,
ToolInput,
ToolOutput,
} from "@/components/ai-elements/tool"<Tool>
<ToolHeader
title="Search Web"
type="tool-search-web"
state="output-available"
/>
<ToolContent>
<ToolInput input={input} />
<ToolOutput output={output} errorText={undefined} />
</ToolContent>
</Tool>Examples
Default
Parameters
{ "query": "latest AI developments", "maxResults": 5}Result
{ "results": [ { "title": "New AI Model Released", "url": "https://example.com/ai-news", "snippet": "A groundbreaking AI model was announced today..." } ]}import {
Tool,
ToolContent,
ToolHeader,
ToolInput,
ToolOutput,
} from "@/components/ai-elements/tool"
export function ToolDemo() {
const toolData = {
type: "tool-search-web",
state: "output-available" as const,
input: {
query: "latest AI developments",
maxResults: 5,
},
output: {
results: [
{
title: "New AI Model Released",
url: "https://example.com/ai-news",
snippet: "A groundbreaking AI model was announced today...",
},
],
},
errorText: undefined,
}
return (
<Tool defaultOpen>
<ToolHeader
title="Search Web"
type={toolData.type}
state={toolData.state}
/>
<ToolContent>
<ToolInput input={toolData.input} />
<ToolOutput output={toolData.output} errorText={toolData.errorText} />
</ToolContent>
</Tool>
)
}
const toolData = {
type: "tool-search-web",
state: "output-available" as const,
input: {
query: "latest AI developments",
maxResults: 5,
},
output: {
results: [
{
title: "New AI Model Released",
url: "https://example.com/ai-news",
snippet: "A groundbreaking AI model...",
},
],
},
errorText: undefined,
}
export default function Example() {
return (
<Tool defaultOpen>
<ToolHeader
title="Search Web"
type={toolData.type}
state={toolData.state}
/>
<ToolContent>
<ToolInput input={toolData.input} />
<ToolOutput output={toolData.output} errorText={toolData.errorText} />
</ToolContent>
</Tool>
)
}Tool States
The component supports different states:
input-streaming: Tool input is being receivedinput-available: Input received, waiting to runoutput-available: Tool has completed successfullyoutput-error: Tool execution failed
API Reference
Tool
Collapsible container for tool call.
| Prop | Type | Default | Description |
|---|---|---|---|
defaultOpen | boolean | false | Initial open state |
className | string | - | Custom CSS classes |
ToolHeader
Header showing tool name and status.
| Prop | Type | Default | Description |
|---|---|---|---|
title | string | - | Tool display name |
type | string | - | Tool type identifier |
state | "input-streaming" | "input-available" | "output-available" | "output-error" | - | Current state |
className | string | - | Custom CSS classes |
ToolInput
Display tool input parameters.
| Prop | Type | Default | Description |
|---|---|---|---|
input | any | - | Tool input data |
className | string | - | Custom CSS classes |
ToolOutput
Display tool output or error.
| Prop | Type | Default | Description |
|---|---|---|---|
output | any | - | Tool output data |
errorText | string | - | Error message if failed |
className | string | - | Custom CSS classes |