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.
What this skill does
# AI Elements Chatbot Components
**Status**: Production Ready ✅ | **Last Verified**: 2025-11-18
---
## What Is AI Elements?
Production-ready chat UI components for AI applications:
- Built on shadcn/ui
- 30+ components (Message, Conversation, Response, etc.)
- Works with Vercel AI SDK v5
- Streaming support
- Tool/function call displays
- Reasoning visualization
---
## Quick Start (15 Minutes)
### Prerequisites
- Next.js 15+ (App Router)
- shadcn/ui initialized
- Tailwind v4
- AI SDK v5+
### 1. Initialize
```bash
pnpm dlx ai-elements@latest init
```
### 2. Add Components
```bash
pnpm dlx ai-elements@latest add message conversation response prompt-input
```
### 3. Create Chat Interface
```typescript
'use client';
import { useChat } from 'ai/react';
import { Conversation } from '@/components/ui/ai/conversation';
import { Message } from '@/components/ui/ai/message';
import { Response } from '@/components/ui/ai/response';
import { PromptInput } from '@/components/ui/ai/prompt-input';
export default function ChatPage() {
const { messages, input, handleInputChange, handleSubmit } = useChat({
api: '/api/chat'
});
return (
<div className="flex h-screen flex-col">
<Conversation>
{messages.map((msg) => (
<Message key={msg.id} role={msg.role}>
<Response markdown={msg.content} />
</Message>
))}
</Conversation>
<PromptInput
value={input}
onChange={handleInputChange}
onSubmit={handleSubmit}
/>
</div>
);
}
```
**Load `references/setup-guide.md` for complete setup.**
---
## Core Components
### Message & Conversation
```typescript
import { Conversation } from '@/components/ui/ai/conversation';
import { Message } from '@/components/ui/ai/message';
<Conversation>
{messages.map((msg) => (
<Message key={msg.id} role={msg.role}>
{msg.content}
</Message>
))}
</Conversation>
```
### Response (Markdown)
```typescript
import { Response } from '@/components/ui/ai/response';
<Response markdown={content} />
```
### PromptInput
```typescript
import { PromptInput } from '@/components/ui/ai/prompt-input';
<PromptInput
value={input}
onChange={handleInputChange}
onSubmit={handleSubmit}
/>
```
### CodeBlock
```typescript
import { CodeBlock } from '@/components/ui/ai/code-block';
<CodeBlock code={code} language="typescript" />
```
### Reasoning (Thinking)
```typescript
import { Reasoning } from '@/components/ui/ai/reasoning';
<Reasoning content={thinking} />
```
### Tool (Function Calls)
```typescript
import { Tool } from '@/components/ui/ai/tool';
<Tool name="search" args={{ query: "..." }} result={result} />
```
---
## Critical Rules
### Always Do ✅
1. **Install shadcn/ui first** (AI Elements requires it)
2. **Use Next.js App Router** (Pages Router not supported)
3. **Use AI SDK v5** (breaking changes from v4)
4. **Install via CLI** (`pnpm dlx ai-elements@latest`)
5. **Update components.json** with registry
6. **Use client components** ('use client' directive)
7. **Stream responses** for better UX
8. **Handle loading states**
9. **Add error boundaries**
10. **Test on mobile**
### Never Do ❌
1. **Never install as npm package** (components are copied)
2. **Never use Pages Router** (only App Router)
3. **Never use AI SDK v4** (breaking changes)
4. **Never skip prerequisites** (shadcn/ui, Tailwind)
5. **Never modify core types** (extends shadcn types)
6. **Never use without streaming** (defeats purpose)
7. **Never skip accessibility** (ARIA labels)
8. **Never hardcode styles** (use Tailwind)
9. **Never skip error handling** (API failures)
10. **Never ignore mobile** (responsive required)
---
## Available Components (30+)
**Core:**
- Message
- Conversation
- Response
- PromptInput
**Content:**
- CodeBlock
- Markdown
- Tool
- Reasoning
- Sources
**Actions:**
- Actions
- CopyButton
- ShareButton
- RegenerateButton
**Advanced:**
- BranchNavigation
- ThinkingDisplay
- WebPreview
---
## Common Use Cases
### Use Case 1: Basic Chat
```typescript
const { messages, input, handleInputChange, handleSubmit } = useChat();
return (
<>
<Conversation>
{messages.map(m => (
<Message key={m.id} role={m.role}>
<Response markdown={m.content} />
</Message>
))}
</Conversation>
<PromptInput value={input} onChange={handleInputChange} onSubmit={handleSubmit} />
</>
);
```
### Use Case 2: With Tool Calls
```typescript
{messages.map(m => (
<Message key={m.id} role={m.role}>
{m.toolInvocations?.map(tool => (
<Tool key={tool.toolCallId} name={tool.toolName} args={tool.args} result={tool.result} />
))}
<Response markdown={m.content} />
</Message>
))}
```
### Use Case 3: With Reasoning
```typescript
<Message role="assistant">
{reasoning && <Reasoning content={reasoning} />}
<Response markdown={content} />
</Message>
```
### Use Case 4: With Code Blocks
```typescript
<Response markdown={content}>
{(node) => node.type === 'code' ? (
<CodeBlock code={node.value} language={node.lang} />
) : null}
</Response>
```
### Use Case 5: With Sources
```typescript
<Message role="assistant">
<Response markdown={content} />
<Sources sources={sources} />
</Message>
```
---
## API Routes
### Basic Streaming
```typescript
// app/api/chat/route.ts
import { streamText } from 'ai';
import { openai } from '@ai-sdk/openai';
export async function POST(req: Request) {
const { messages } = await req.json();
const result = streamText({
model: openai('gpt-4'),
messages
});
return result.toDataStreamResponse();
}
```
### With Tools
```typescript
const result = streamText({
model: openai('gpt-4'),
messages,
tools: {
search: {
description: 'Search the web',
parameters: z.object({ query: z.string() }),
execute: async ({ query }) => {
return await search(query);
}
}
}
});
```
---
## When to Use AI Elements
**Use when:**
- Building ChatGPT-style interface
- Need production-ready components
- Using Vercel AI SDK
- Want streaming responses
- Need tool/function displays
- Want reasoning visualization
**Don't use when:**
- Not using Next.js App Router
- Don't have shadcn/ui
- Need Pages Router
- Building custom design system
---
## Resources
**References** (`references/`):
- `component-catalog.md` - All 8 AI Elements components with examples
- `example-reference.md` - Complete integration examples and patterns
- `setup-guide.md` - Step-by-step setup with Next.js 15 and shadcn/ui
**Templates** (`templates/`):
- Component examples available in reference files
---
## Official Documentation
- **AI Elements**: https://ai-elements.vercel.app
- **Components**: https://ai-elements.vercel.app/docs/components
- **Examples**: https://github.com/ai-elements/ai-elements/tree/main/examples
---
**Questions? Issues?**
1. Check `references/setup-guide.md` for complete setup
2. Verify prerequisites (Next.js 15+, shadcn/ui, AI SDK v5)
3. See official examples
Related in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.