AI Right Sidebar
Collapsible right sidebar for AI chat interfaces with multi-tab navigation. Features chat, context management, conversation history, and settings panels in a Perplexity Comet-style design.
Preview
Full-featured sidebar with all tabs
Main Content Area
This area represents your main application content. The sidebar on the right provides AI assistance without blocking the main view.
Non-modal: Content adjusts when sidebar opens/closes.
Multi-section: Chat, Context, History, and Settings tabs.
AI Assistant
Hi! I can help you with information about the current context. What would you like to know?
10:32 AMWidth Variants
Three width presets: narrow, medium, wide
Narrow (280px)
AI Assistant
Hi! I can help you with information about the current context. What would you like to know?
10:32 AMMedium (360px)
AI Assistant
Hi! I can help you with information about the current context. What would you like to know?
10:32 AMWide (480px)
AI Assistant
Hi! I can help you with information about the current context. What would you like to know?
10:32 AMCustom Resources
Provide your own context resources
AI Assistant
Active Resources
Props
AIRightSidebar component API reference
| Prop | Type | Default | Description |
|---|---|---|---|
isOpen | boolean | true | Whether the sidebar is open |
onToggle | () => void | — | Callback when the sidebar is toggled |
width | 'narrow' | 'medium' | 'wide' | 'medium' | Sidebar width preset (280px, 360px, 480px) |
resizable | boolean | true | Enable drag-to-resize functionality |
pinnable | boolean | true | Show pin button in header |
sections | SidebarSection[] | ['chat', 'context', 'history', 'settings'] | Available tab sections to display |
defaultActiveTab | SidebarSection | 'chat' | Initial active tab |
defaultPinned | boolean | false | Initial pinned state |
messages | Message[] | (default messages) | Chat messages to display |
resources | Resource[] | (default resources) | Context resources to display |
historyItems | HistoryItem[] | (default items) | History items to display |
onSend | (message: string) => void | — | Callback when a message is sent |
onResourceToggle | (resourceId: string) => void | — | Callback when a resource is toggled |
onHistorySelect | (item: HistoryItem) => void | — | Callback when a history item is clicked |
className | string | — | Additional CSS classes for the container |
Resource Type
| Prop | Type | Default | Description |
|---|---|---|---|
id* | string | — | Unique resource identifier |
icon* | LucideIcon | — | Icon component to display |
label* | string | — | Resource label |
description* | string | — | Resource description |
active* | boolean | — | Whether resource is active |
Message Type
| Prop | Type | Default | Description |
|---|---|---|---|
id* | string | number | — | Unique message identifier |
role* | 'assistant' | 'user' | — | Message sender role |
content* | string | — | Message content |
time* | string | — | Message timestamp |
Usage
Import and implementation example
import { AIRightSidebar } from '@/blocks/ai-tools/ai-right-sidebar'
import { Globe, Brain, Upload } from 'lucide-react'
export default function Example() {
const [isOpen, setIsOpen] = useState(true)
const resources = [
{ id: 'web', icon: Globe, label: 'Web Search', description: 'Search the internet', active: true },
{ id: 'kb', icon: Brain, label: 'Knowledge Base', description: 'Company docs', active: false },
{ id: 'files', icon: Upload, label: 'Files', description: '3 files attached', active: true },
]
const handleSend = (message: string) => {
console.log('Sending:', message)
}
return (
<div className="flex h-screen">
<main className="flex-1">
{/* Your main content */}
</main>
<AIRightSidebar
isOpen={isOpen}
onToggle={() => setIsOpen(!isOpen)}
width="medium"
resources={resources}
onSend={handleSend}
onResourceToggle={(id) => console.log('Toggle:', id)}
/>
</div>
)
}Features
Built-in functionality
- Non-modal design: Sidebar adjusts content width, never overlays
- Multi-section tabs: Chat, Context, History, and Settings in one interface
- Width presets: Narrow (280px), medium (360px), and wide (480px) options
- Pinnable: Pin button to keep sidebar always open
- Context management: Toggle active resources like web search and knowledge base
- Chat interface: Built-in message display and input with send button
- Conversation history: Access previous conversations with timestamps
- Settings panel: Model selection and temperature controls
- Smooth transitions: Animated tab switching and hover states
- Dark mode: Full dark mode support with proper gradients
Accessibility
Accessibility considerations
ARIA Attributes
Tab buttons are native button elementsChat input is a native input elementPin and close buttons have visual indicatorsKeyboard Navigation
| Key | Action |
|---|---|
| Tab | Navigate between tabs, input, and action buttons |
| Enter | Send message when input is focused |
| Enter / Space | Activate focused tab or button |
Notes
- Active tab has visible border and background highlight
- Pinned state shows with indigo background on pin button
- Resource active state indicated with indigo background
- Consider adding aria-selected to tab buttons
- Consider adding role="tablist" and role="tabpanel"