Overview
The CometChatConversations component displays a real-time list of conversations (both user and group conversations) for the logged-in user. It provides a rich set of features including real-time updates, search functionality, selection modes, keyboard navigation, and extensive customization through templates and styling. The component follows a Hybrid Approach architecture where:- ConversationsService handles all SDK interactions, state management, and real-time updates
- Component @Input properties allow developers to override service behavior for flexibility
- Both service methods and @Input properties are available, with @Input taking priority when provided
Key Features
- Real-time Updates: Automatic updates for new messages, typing indicators, and user status changes
- Flexible Customization: Extensive template projection for all UI sections
- Service-Based Architecture: Clean separation of concerns with Angular best practices
- Keyboard Navigation: Full keyboard accessibility with arrow keys and shortcuts (WCAG 2.1 Level AA compliant)
- Selection Modes: Support for single and multiple conversation selection
- Search Functionality: Built-in search with debouncing
- Context Menu: Customizable actions for each conversation
- Sound Notifications: Optional notification sounds for new messages
- Error Handling: Comprehensive error handling with retry logic
Keyboard Accessibility
CometChatConversations is fully keyboard accessible and meets WCAG 2.1 Level AA standards. All functionality can be accessed using only the keyboard.Keyboard Shortcuts
Context Menu Keyboard Navigation
Accessibility Features
ARIA Attributes:role="list"on conversations containerrole="listitem"on each conversationaria-labelwith conversation details (name, last message, unread count)aria-selectedindicates selected conversationsaria-live="polite"region for screen reader announcements- Proper
tabindexmanagement (roving tabindex pattern)
- Announces conversation details when focused
- Announces selection state changes
- Announces when search bar is focused
- Live region for dynamic updates
- Semantic HTML structure
- Visible focus indicators (2px border) meeting WCAG contrast requirements
- Focus trap within modals (delete confirmation)
- Focus restoration after closing overlays
- Roving tabindex for efficient keyboard navigation
- High contrast mode support
- ✅ 2.1.1 Keyboard (Level A) - All functionality available via keyboard
- ✅ 2.1.2 No Keyboard Trap (Level A) - Users can navigate away using keyboard
- ✅ 2.4.3 Focus Order (Level A) - Logical focus order
- ✅ 2.4.7 Focus Visible (Level AA) - Visible focus indicators
- ✅ 4.1.2 Name, Role, Value (Level A) - Proper ARIA attributes
- ✅ 4.1.3 Status Messages (Level AA) - Screen reader announcements
Customizing Keyboard Behavior
The component’s keyboard handlers are scoped to the list container and won’t interfere with your application’s global keyboard shortcuts. If you need to disable specific shortcuts, handle this at the application level:Basic Usage
Simple Implementation
With Custom Title and Search
Live Preview — interact with the default conversations list.
Open in Storybook ↗
Properties
Display Control Properties
Data Configuration Properties
Customization Properties
Sound Configuration Properties
Template Properties
Events
Usage Patterns
CometChatConversations supports two usage patterns. The default service-based approach usesChatStateService to automatically wire downstream components. Alternatively, you can pass data explicitly via @Input() bindings.
- Using Service
- Using Props
When a user clicks a conversation,
ChatStateService stores the active user or group. Downstream components like cometchat-message-header, cometchat-message-list, and cometchat-message-composer automatically subscribe to state changes — no explicit prop passing required.Advanced Usage
Filtering Conversations
Use theconversationsRequestBuilder to filter conversations by type, tags, or other criteria:
Selection Mode
Enable single or multiple conversation selection:Custom Context Menu Options
Provide custom actions for each conversation:Customization with Templates
Custom Subtitle View
Customize the message preview section:Custom Leading View with Status
Customize the avatar and status indicator:Live Preview — conversations list with custom templates applied.
Open in Storybook ↗
Custom Empty and Error States
Provide custom views for empty and error states:Slot-Based Customization
Theslots input provides fine-grained control over individual UI elements within each conversation item. Unlike section-level templates (leadingView, subtitleView, etc.) which replace entire sections, slots let you override a single element — like just the avatar, just the unread badge, or just the timestamp — while keeping everything else at its default.
When to Use Slots vs Templates
Available Slots
Slots are organized into three sections of the conversation item: Leading section (left side):
Body section (center):
Trailing section (right side):
ConversationSlotContext
Every slot template receives aConversationSlotContext object as its implicit variable, plus any slot-specific extras:
Usage
Import the types:Override a single slot
Override multiple slots
Slots are passed through to
CometChatConversationItem internally. The slots input on CometChatConversations applies the same slots to every item in the list.Service Configuration (Hybrid Approach)
The component supports both service-level and component-level configuration. Service configuration applies globally to all component instances, while component @Input properties override service settings for specific instances.Global Service Configuration
Configure the ConversationsService to set defaults for all component instances:Per-Instance Override
Override service configuration for specific component instances:Setting Active Conversation
Set the active conversation globally or per-instance:Styling with CSS Variables
The CometChatConversations component uses CSS variables for comprehensive theming:Dark Theme Example
Custom Brand Colors
Accessibility
The CometChatConversations component includes comprehensive accessibility features to ensure usability for all users.Keyboard Navigation
ARIA Support
The component includes proper ARIA attributes for screen reader compatibility:role="list"on the conversation list containerrole="listitem"on each conversation itemaria-labelwith conversation name and last message previewaria-selectedattribute based on selection statearia-live="polite"for real-time updates announcementstabindexmanagement for keyboard navigation
Screen Reader Announcements
The component announces important state changes to screen readers:- New message received: “New message from [User Name]”
- Conversation selected: “Conversation with [User Name] selected”
- Typing indicator: “[User Name] is typing”
- Error states: “Error loading conversations”
- Empty state: “No conversations available”
Focus Management
- Clear focus indicators using the primary color
- Focus is maintained when navigating with keyboard
- Focus returns to the last focused item after menu interactions
- Focus is trapped within modal dialogs (context menus)
High Contrast Mode
The component supports high contrast mode with enhanced visual indicators:Reduced Motion
Respects user’s motion preferences:Real-Time Features
Automatic Updates
The component automatically updates in real-time for:- New Messages: Conversations move to the top when new messages arrive
- Message Updates: Edited or deleted messages update the preview
- Typing Indicators: Shows when users are typing
- User Status: Online/offline status updates in real-time
- Read Receipts: Updates when messages are read
- Unread Count: Badge updates automatically
Sound Notifications
Enable sound notifications for new messages:Typing Indicators
Typing indicators are shown automatically in the subtitle section:Error Handling
Built-in Error Handling
The component includes comprehensive error handling:Retry Logic
The service includes automatic retry logic with exponential backoff for recoverable errors:- Network errors: Retries up to 3 times
- Timeout errors: Retries with increasing delays (1s, 2s, 4s)
- Authentication errors: No retry (requires user action)
Custom Error View
Provide a custom error view with retry functionality:For troubleshooting tips, see the Troubleshooting Guide.
Best Practices
The component uses
OnPush change detection strategy for optimal performance. If you’re using custom templates with external state, ensure proper change detection triggering.The component automatically handles pagination when scrolling to the bottom. You don’t need to implement pagination logic manually.
Complete Example
Here’s a comprehensive example combining multiple features:Related Components
- CometChatMessageList: Display messages for a selected conversation
- CometChatUsers: List and select users to start conversations
- CometChatGroups: List and select groups to start conversations
- CometChatSearchBar: Search component used in the conversations header
- CometChatContextMenu: Context menu for conversation actions
- CometChatAvatar: Avatar component used in conversation items
Technical Details
- Standalone Component: Can be imported and used independently
- Change Detection: Uses
OnPushstrategy for optimal performance - Service Architecture: All SDK logic in ConversationsService
- Real-time Updates: Automatic via SDK listeners
- Pagination: Automatic on scroll with intersection observers
- Accessibility: WCAG 2.1 Level AA compliant
- BEM CSS: Follows Block Element Modifier naming convention
- Bundle Size: Optimized for production builds
Browser Compatibility
The CometChatConversations component is compatible with all modern browsers:- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)