Installation
- CLI
- Manual
Install the block using the shadcn CLI:This will automatically install the following dependencies:
@tabler/icons-react
buttondropdown-menutextarea
Usage
Features
This AI chat component provides a modern, expandable interface with the following features:Dynamic Layout - The component intelligently expands from a compact single-line input to a multi-line interface as users type longer messages or multi-line content.
Voice Input
- Audio Recording - Built-in microphone button for voice message recording
- Audio Visualization - Wave visualization button to display audio feedback
- Multi-modal Input - Seamlessly switch between text and voice input
Smart Attachments
- File Uploads - Add photos and files through a dropdown menu
- Agent Mode - Enable AI agent capabilities for advanced interactions
- Deep Research - Trigger comprehensive research mode
Auto-Expanding Textarea
- Automatically adjusts height based on content
- Supports multi-line input with proper formatting
- Expands layout when content exceeds 100 characters or includes line breaks
Keyboard Shortcuts
- Enter - Submit message
- Shift + Enter - New line
Component Props
This component doesn’t accept external props. All state is managed internally.Customization
The component uses a grid-based layout system that adapts based on theisExpanded state:
Styling Options
- Modify the
max-w-2xlclass to change the maximum width - Customize the rounded corners by changing
rounded-3xl - Adjust the expansion threshold by modifying the condition:
e.target.value.length > 100
Adding Custom Actions
Extend the dropdown menu with additional options:Implementation Details
The component manages several state variables:message- Current input textisExpanded- Layout expansion statetextareaRef- Reference for auto-resizingfileInputRef- Reference for file upload input
handleTextareaChange function automatically adjusts the textarea height: