setInput(e.target.value)}
onSubmit={handleSubmit}
placeholder="Type a message..."
/>
```
---
## AI Reasoning Components
### Reasoning (Collapsible Thinking)
Auto-opens during streaming, collapses when done.
```tsx
import {
Reasoning,
ReasoningTrigger,
ReasoningContent,
} from '@/components/ai-elements/reasoning';
{reasoningText}
```
### Chain of Thought
Visual step-by-step reasoning with search results, images, progress.
```tsx
import { ChainOfThought } from '@/components/ai-elements/chain-of-thought';
Searching for profiles...
x.com
github.com
```
### Plan & Task
Display agent plans and individual tasks.
```tsx
import { Plan, Task } from '@/components/ai-elements/plan';
Set up project structure
Implement core features
Write tests
```
---
## Interactivity Components
### Confirmation (Tool Approval)
Manage tool execution approval workflows.
```tsx
import {
Confirmation,
ConfirmationRequest,
ConfirmationAccepted,
ConfirmationRejected,
ConfirmationActions,
ConfirmationAction,
} from '@/components/ai-elements/confirmation';
This tool wants to delete: {tool.input?.filePath}
Do you approve?
File deleted successfully
Action cancelled
respondToConfirmationRequest({ approvalId, approved: false })}>
Reject
respondToConfirmationRequest({ approvalId, approved: true })}>
Approve
```
### Suggestion (Quick Prompts)
Horizontal row of clickable suggestions.
```tsx
import { Suggestions, Suggestion } from '@/components/ai-elements/suggestion';
const prompts = [
'How do I get started?',
'What can you help with?',
'Show me examples',
];
{prompts.map((prompt) => (
setInput(text)}
/>
))}
```
### Tool
Display tool calls and results.
```tsx
import { Tool, ToolContent, ToolResult } from '@/components/ai-elements/tool';
Searching for: {tool.args.query}
{tool.result}
```
### Checkpoint (Restore Points)
Mark and restore conversation history.
```tsx
import {
Checkpoint,
CheckpointIcon,
CheckpointTrigger,
} from '@/components/ai-elements/checkpoint';
restoreToCheckpoint(index)}>
Restore to this point
```
---
## Citation Components
### Sources
Collapsible source citations.
```tsx
import {
Sources,
SourcesTrigger,
SourcesContent,
Source,
} from '@/components/ai-elements/sources';
```
### Inline Citation
Citations within text content.
```tsx
import { InlineCitation } from '@/components/ai-elements/inline-citation';
According to the documentation
, you should...
```
---
## Loading Components
### Queue
Message queue/loading state.
```tsx
import { Queue } from '@/components/ai-elements/queue';
Processing your request...
```
### Shimmer
Skeleton loading placeholder.
```tsx
import { Shimmer } from '@/components/ai-elements/shimmer';
{isLoading && }
```
---
## Utility Components
### Model Selector
Switch between AI models.
```tsx
import { ModelSelector } from '@/components/ai-elements/model-selector';
```
### Context
Display context information.
```tsx
import { Context } from '@/components/ai-elements/context';
Working on: Project Alpha
Files: 3 selected
```
---
## Complete Chat Example
```tsx
'use client';
import { useState } from 'react';
import { useChat } from 'ai/react';
import {
Conversation,
ConversationContent,
ConversationEmptyState,
ConversationScrollButton,
} from '@/components/ai-elements/conversation';
import { Message, MessageContent } from '@/components/ai-elements/message';
import { PromptInput } from '@/components/ai-elements/prompt-input';
import { Reasoning, ReasoningTrigger, ReasoningContent } from '@/components/ai-elements/reasoning';
import { Suggestions, Suggestion } from '@/components/ai-elements/suggestion';
import { Sources, SourcesTrigger, SourcesContent, Source } from '@/components/ai-elements/sources';
export function Chat() {
const { messages, input, setInput, handleSubmit, isLoading } = useChat();
const suggestions = [
'What can you help me with?',
'Tell me about AI SDK',
'How do I get started?',
];
return (
{messages.length === 0 ? (
<>
{suggestions.map((s) => (
))}
>
) : (
messages.map((msg) => (
{msg.content}
{/* Show reasoning if available */}
{msg.reasoning && (
{msg.reasoning}
)}
{/* Show sources if available */}
{msg.sources?.length > 0 && (
{msg.sources.map((src, i) => (
))}
)}
))
)}
);
}
```
---
## Styling
All components accept `className` prop for Tailwind customization:
```tsx
{content}
```
---
## Integration with AI SDK
These components work seamlessly with Vercel AI SDK hooks:
```tsx
import { useChat } from 'ai/react';
import { useCompletion } from 'ai/react';
import { useAssistant } from 'ai/react';
// useChat for conversational interfaces
const { messages, input, handleSubmit } = useChat();
// useCompletion for single completions
const { completion, complete } = useCompletion();
// useAssistant for OpenAI Assistants
const { messages, submitMessage } = useAssistant();
```
---
## Reference
See `references/component-api.md` for complete props documentation.