ChatBubbles Component
TheChatBubbles component provides a polished chat message display with smooth animations, intelligent message grouping, auto-scrolling behavior, and integrated typing indicators. It automatically renders messages using Cedar’s message rendering system and adapts to different container sizes.
Features
- Smooth Animations: Framer Motion powered message entrance animations
- Auto-Scrolling: Automatic scroll to bottom on new messages
- Message Grouping: Consecutive messages from same sender are visually grouped
- Typing Indicator: Animated typing indicator during message processing
- Flexible Sizing: Support for both fixed height and flexible containers
- Performance Optimized: Efficient scrolling with paint containment
- Dark Mode: Full dark mode support with theme integration
- Custom Scrollbar: Styled scrollbars for better visual integration
Import
Basic Usage
Advanced Usage
With Custom Container Styling
In a Chat Interface Layout
With Constrained Height
Props
string
Maximum height for the message container. When provided, creates a
fixed-height scrollable container. When omitted, uses flex-1 for flexible
height. Examples: “300px”, “60vh”, “20rem”
string
default:""
Additional CSS classes for the container. Applied to the outer container
element.
Behavior
Message Grouping
The component automatically groups consecutive messages from the same sender:- First message in a group: Full spacing (mt-2)
- Consecutive messages: Reduced spacing (mt-1)
- Different senders: Full spacing between groups
Auto-Scrolling
- Initial render: Immediate scroll to bottom (useLayoutEffect)
- New messages: Smooth scroll to bottom when messages change
- Performance: Uses
scrollTowith smooth behavior for fluid UX
Typing Indicator
WhenisProcessing is true in the Cedar store:
- Shows animated typing dots
- Positioned as assistant message
- Smooth entrance/exit animations
- Themed to match current styling
Message Rendering
The component integrates with Cedar’s message rendering system:- Uses
ChatRendererfor individual message display - Supports all Cedar message types (text, tool calls, human-in-the-loop, etc.)
- Automatic message type detection and appropriate rendering
- Custom message renderers are supported through Cedar’s renderer system
Styling and Theming
Container Styling
Scrollbar Customization
The component includes custom scrollbar styling:Message Animations
Messages use Framer Motion with these default animations:Integration Examples
Complete Chat Application
Embedded Chat Widget
Multi-Column Layout
Performance Considerations
Container Optimization
Scroll Performance
- Uses
scrollToinstead ofscrollIntoViewfor better control - Immediate scroll on initial render prevents flash
- Smooth scrolling for subsequent updates
Animation Performance
- Uses
will-change: transformfor smooth animations - Blur effects are hardware accelerated
- Short animation duration (0.15s) for responsiveness
Accessibility
Screen Reader Support
- Messages are announced as they appear
- Proper semantic structure with message roles
- Typing indicator is announced appropriately
Keyboard Navigation
- Scrollable content is keyboard accessible
- Focus management integrates with ChatInput
- Proper tab order maintained
Visual Accessibility
- High contrast support in both light and dark modes
- Respects user’s motion preferences
- Clear visual hierarchy with proper spacing

