ChatInput Components
The ChatInput components provide a comprehensive chat interface with rich text editing, context management, voice integration, and multiple display variants. Built on Cedar’s editor system with full integration into the Cedar ecosystem.Components Overview
- ChatInput - Main chat input component with voice and context support
- ContextBadgeRow - Displays and manages selected context entries
- FloatingChatInput - Floating variant for overlay interfaces
- HumanInTheLoopIndicator - Shows workflow suspension states
Import
ChatInput
The main chat input component with integrated voice support, context management, and rich text editing.Basic Usage
Advanced Usage with Controlled State
Props
() => void
Callback when the input gains focus
() => void
Callback when the input loses focus
boolean
Controlled focus state for the input
string
default:""
Additional CSS classes for the container
boolean
default:"true"
Whether to use streaming for responses
Features
- Voice Integration: Built-in microphone button with voice permission handling
- Context Management: Integrated ContextBadgeRow for managing selected context
- Rich Text Editing: Uses Cedar’s editor with mention support
- Human-in-the-Loop: Automatic detection and display of workflow suspension states
- Keyboard Shortcuts:
Tab- Focus the inputEscape- Unfocus the inputM- Toggle microphone (when not typing)
- Tool Buttons: Microphone, image upload, and code insertion tools
ContextBadgeRow
Displays and manages context entries selected through mentions or other context providers.Basic Usage
Props
CedarEditor | null
The Cedar editor instance for mention management
Features
- Dynamic Context Display: Shows context entries from all registered providers
- Custom Rendering: Supports provider-specific badge rendering
- Interactive Removal: Click to remove context entries (for mentions)
- Ordered Display: Respects context entry order metadata
- Icon Support: Displays icons with hover states for removal
- Color Coding: Supports custom colors with 20% opacity backgrounds
Context Entry Structure
FloatingChatInput
A floating variant of the chat input for overlay interfaces and popup scenarios.Basic Usage
Advanced Usage
Props
{ x: number; y: number }
required
Screen coordinates where the floating input should appear
() => void
required
Callback when the input should close
boolean
default:"true"
Whether to use streaming for responses
number
default:"400"
Width of the floating input in pixels
string
Additional CSS classes for styling
boolean
default:"true"
Whether to auto-focus the input on mount
Features
- Smart Positioning: Automatically adjusts position to stay within viewport
- Click Outside: Closes when clicking outside the component
- Escape Key: Closes when pressing Escape
- Header with Close Button: Clean header with close action
- Full ChatInput Integration: All ChatInput features in a floating container
HumanInTheLoopIndicator
Shows the current state of human-in-the-loop workflows.Basic Usage
Props
'suspended' | 'resumed' | 'cancelled' | 'timeout'
required
The current workflow state to display
State Indicators
- suspended - Orange pause icon with “Workflow suspended…” message
- resumed - Green play icon with “Workflow resumed” message
- cancelled - Red X icon with “Workflow cancelled” message
- timeout - Gray clock icon with “Workflow timed out” message
Integration Examples
Complete Chat Interface
Context-Aware Input
Floating Quick Chat
Voice Integration
The ChatInput components include comprehensive voice support:Voice States
- Idle - Default state, microphone available
- Listening - Actively recording audio (red, pulsing)
- Speaking - AI is speaking response (green)
- Denied - Microphone permission denied (grayed out)
- Not Supported - Voice not supported in browser
Voice Permissions
The component automatically handles microphone permissions:Styling and Customization
CSS Classes
The components use Tailwind CSS with dark mode support:Theme Integration
Components automatically adapt to Cedar’s theme system and respect the global styling configuration.Accessibility
- Keyboard Navigation: Full keyboard support for all interactions
- Screen Readers: Proper ARIA labels and descriptions
- Focus Management: Logical focus flow and indicators
- High Contrast: Supports high contrast mode and custom themes
Best Practices
Performance
- Use controlled focus state only when necessary
- Implement proper cleanup for event listeners
- Consider virtualization for large context lists
UX Guidelines
- Provide clear feedback for voice states
- Show context visually before sending messages
- Handle permission requests gracefully
- Use floating inputs sparingly to avoid UI clutter
Integration
- Always pair with ChatBubbles for complete chat UI
- Register context providers before using mentions
- Configure voice endpoints in Cedar store
- Test voice functionality across different browsers

