ai-elements
AI Elements component library for AI-native applications. Use when building chatbots, AI workflows, or integrating with Vercel AI SDK's useChat hook.
Best use case
ai-elements is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
AI Elements component library for AI-native applications. Use when building chatbots, AI workflows, or integrating with Vercel AI SDK's useChat hook.
Teams using ai-elements should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/ai-elements/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How ai-elements Compares
| Feature / Agent | ai-elements | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
AI Elements component library for AI-native applications. Use when building chatbots, AI workflows, or integrating with Vercel AI SDK's useChat hook.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# AI Elements
Build AI-native applications with pre-built components on shadcn/ui.
## Quick Start
```bash
# Install all AI Elements components
bunx --bun ai-elements@latest
# or via shadcn CLI
bunx --bun shadcn@latest add @ai-elements/all
# Install AI SDK dependencies
bun add ai @ai-sdk/react zod
```
Components install to `@/components/ai-elements/`.
## Component Quick Reference
### Chatbot Components
| Component | Purpose |
|-----------|---------|
| `Conversation` | Auto-scroll chat container |
| `Message` | Single message wrapper (user/assistant) |
| `MessageResponse` | Streaming markdown renderer (uses `streamdown`) |
| `PromptInput` | Rich input with attachments, model picker |
| `Reasoning` | Collapsible thinking display |
| `Sources` | Citation/reference display |
| `Tool` | Tool execution visualization |
| `ChainOfThought` | Step-by-step breakdown |
| `InlineCitation` | Inline citation badge with hover card carousel |
| `Plan` | Collapsible plan card with streaming title |
| `Task` | Collapsible task breakdown display |
| `Queue` | Todo/message queue with sections |
### Workflow Components
| Component | Purpose |
|-----------|---------|
| `Canvas` | React Flow wrapper for visual workflows |
| `Node` | Workflow node with header/content/footer |
| `Edge` | Animated/temporary edge connections |
| `Controls` | Zoom/fit view controls |
| `Panel` | Positioned overlay panels |
| `Context` | Token usage tracking display |
### Utility Components
| Component | Purpose |
|-----------|---------|
| `CodeBlock` | Syntax highlighted code (Shiki) |
| `Loader` | Loading indicator |
| `Shimmer` | Streaming text effect |
| `Confirmation` | Tool confirmation dialog |
| `Suggestion` | Quick action chips |
| `ModelSelector` | Model picker dialog with provider logos |
| `OpenIn` | Open query in external chat (ChatGPT, Claude, etc.) |
| `WebPreview` | Iframe preview with URL bar and console |
## Core Integration Pattern
```tsx
'use client';
import { useChat } from '@ai-sdk/react';
import { Conversation, ConversationContent } from '@/components/ai-elements/conversation';
import { Message, MessageContent, MessageResponse } from '@/components/ai-elements/message';
import { Reasoning, ReasoningTrigger, ReasoningContent } from '@/components/ai-elements/reasoning';
import { Sources, SourcesTrigger, SourcesContent, Source } from '@/components/ai-elements/sources';
export function Chat() {
const { messages, sendMessage, status } = useChat();
return (
<Conversation>
<ConversationContent>
{messages.map((message) => (
<div key={message.id}>
{message.parts.map((part, i) => {
switch (part.type) {
case 'text':
return (
<Message key={i} from={message.role}>
<MessageContent>
<MessageResponse>{part.text}</MessageResponse>
</MessageContent>
</Message>
);
case 'reasoning':
return (
<Reasoning key={i} isStreaming={status === 'streaming'}>
<ReasoningTrigger />
<ReasoningContent>{part.text}</ReasoningContent>
</Reasoning>
);
case 'source-url':
return <Source key={i} href={part.url} title={part.title} />;
}
})}
</div>
))}
</ConversationContent>
</Conversation>
);
}
```
## API Route Pattern
```typescript
// app/api/chat/route.ts
import { streamText, UIMessage, convertToModelMessages } from 'ai';
export const maxDuration = 30;
export async function POST(req: Request) {
const { messages, model }: { messages: UIMessage[]; model: string } = await req.json();
const result = streamText({
model,
messages: convertToModelMessages(messages),
system: 'You are a helpful assistant.',
});
return result.toUIMessageStreamResponse({
sendSources: true,
sendReasoning: true,
});
}
```
## Key Patterns
### Message Parts Switching
Messages have `parts` array. Switch on `part.type`:
- `text` - Regular text content
- `reasoning` - Model thinking/reasoning
- `source-url` - Citation with URL
- `tool-*` - Tool invocations (input, output, error)
### Compound Components
Most components use compound pattern:
```tsx
<Conversation>
<ConversationContent>{/* messages */}</ConversationContent>
<ConversationScrollButton />
</Conversation>
<Message from="assistant">
<MessageContent>
<MessageResponse>{text}</MessageResponse>
</MessageContent>
<MessageActions>
<MessageAction label="Copy"><CopyIcon /></MessageAction>
</MessageActions>
</Message>
```
### File Attachments
```tsx
<PromptInput onSubmit={handleSubmit} globalDrop multiple>
<PromptInputHeader>
<PromptInputAttachments>
{(attachment) => <PromptInputAttachment data={attachment} />}
</PromptInputAttachments>
</PromptInputHeader>
<PromptInputBody>
<PromptInputTextarea />
</PromptInputBody>
<PromptInputFooter>
<PromptInputTools>
<PromptInputActionMenu>
<PromptInputActionMenuTrigger />
<PromptInputActionMenuContent>
<PromptInputActionAddAttachments />
</PromptInputActionMenuContent>
</PromptInputActionMenu>
</PromptInputTools>
<PromptInputSubmit status={status} />
</PromptInputFooter>
</PromptInput>
```
## References
- [Chatbot Components](references/chatbot.md) - Conversation, Message, PromptInput, Reasoning, Sources, Tool, InlineCitation, Plan, Task, Queue
- [Workflow Components](references/workflow.md) - Canvas, Node, Edge, Controls
- [Utility Components](references/utilities.md) - CodeBlock, Loader, Shimmer, ModelSelector, OpenIn, WebPreview
- [AI SDK Integration](references/integration.md) - useChat, API routes, message parts
## Dependencies
Key dependencies used by AI Elements:
| Package | Purpose |
|---------|---------|
| `streamdown` | Streaming markdown renderer for `MessageResponse` and `Reasoning` |
| `shiki` | Syntax highlighting for `CodeBlock` |
| `use-stick-to-bottom` | Auto-scroll behavior for `Conversation` |
| `motion` | Animations for `Shimmer` |
| `tokenlens` | Token cost calculation for `Context` |
## Package Manager
**Always use bun**, never npm:
- `bun add` (not npm install)
- `bunx --bun` (not npx)Related Skills
ai-elements-chatbot
shadcn/ui AI chat components for conversational interfaces. Use for streaming chat, tool/function displays, reasoning visualization, or encountering Next.js App Router setup, Tailwind v4 integration, AI SDK v5 migration errors.
bgo
Automates the complete Blender build-go workflow, from building and packaging your extension/add-on to removing old versions, installing, enabling, and launching Blender for quick testing and iteration.
pcf-tooling
Get Microsoft Power Platform CLI tooling for Power Apps Component Framework Triggers on: **/*.{ts,tsx,js,json,xml,pcfproj,csproj}
pcf-code-components
Understanding code components structure and implementation Triggers on: **/*.{ts,tsx,js,json,xml,pcfproj,csproj}
pcf-canvas-apps
Code components for canvas apps implementation, security, and configuration Triggers on: **/*.{ts,tsx,js,json,xml,pcfproj,csproj}
nextjs15-react19-vercelai-tailwind-cursorrules-prompt-file-cursorrules
Apply for nextjs15-react19-vercelai-tailwind-cursorrules-prompt-file. --- description: Best practices for using Tailwind CSS in Next.js 15 and React 19 applications, including responsive design, custom configurations, and performance optimization. globs: app/**/*
nextjs
Next.js framework best practices including App Router, data fetching, and performance optimization.
nextjs-supabase-auth
Expert integration of Supabase Auth with Next.js App Router Use when: supabase auth next, authentication next.js, login supabase, auth middleware, protected route.
Next.js App Router & Server Components
Build Next.js 15 applications using App Router, Server Components, Client Components, Server Actions, and streaming. Apply when creating pages, handling data fetching, implementing routes, or optimizing performance.
moai-domain-frontend
Frontend development specialist covering React 19, Next.js 16, Vue 3.5, and modern UI/UX patterns with component architecture. Use when building web UIs, implementing components, optimizing frontend performance, or integrating state management.
marp-pitch-creator
Create high-quality pitch decks using Marp and Tailwind CSS
marimo
Guide for creating and working with marimo notebooks, the reactive Python notebook that stores as pure .py files. This skill should be used when creating, editing, running, or deploying marimo notebooks.