Overview
The CometChatGroups component displays a real-time, scrollable list of groups with support for search, selection modes, and extensive customization. It provides an integral search functionality, allowing you to locate any specific group swiftly and easily. For each group listed, the component displays the group’s name by default, in conjunction with their avatar when available. Furthermore, it includes a group type indicator (public, private, or password-protected) and member count. The component follows a Manager-based Architecture where:- GroupsManager handles SDK request building and pagination
- Component manages state, real-time listeners, and UI rendering
- Templates allow extensive customization of all UI sections
Key Features
- Real-time Updates: Automatic updates for group member events (join, leave, kick, ban)
- Flexible Customization: Extensive template projection for all UI sections
- Selection Modes: Support for single and multiple group selection
- Group Type Indicators: Visual indicators for public, private, and password-protected groups
- Search Functionality: Built-in search with 300ms debouncing
- Keyboard Navigation: Full keyboard accessibility with arrow keys and shortcuts (WCAG 2.1 Level AA compliant)
- Context Menu: Customizable actions for each group
- Error Handling: Comprehensive error handling with custom error views
Live Preview — default groups list preview.
Open in Storybook ↗
Keyboard Accessibility
CometChatGroups is fully keyboard accessible and meets WCAG 2.1 Level AA standards. All functionality can be accessed using only the keyboard.Keyboard Shortcuts
Accessibility Features
ARIA Attributes:role="list"on groups containerrole="listitem"on each group itemaria-labelwith group name, type, and member countaria-selectedindicates selected groups- Proper
tabindexmanagement (roving tabindex pattern)
- Announces group details when focused
- Announces selection state changes
- Announces group type (public/private/password)
- Semantic HTML structure
- Visible focus indicators (2px border) meeting WCAG contrast requirements
- Focus restoration after interactions
- Roving tabindex for efficient keyboard navigation
- ✅ 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
Basic Usage
Simple Implementation
With Search and Group Type Indicators
Properties
Display Control Properties
Data Configuration Properties
Customization Properties
Template Properties
Events
Usage Patterns
CometChatGroups supports two usage patterns for communicating the selected group to downstream components.- Using Service
- Using Props
When a group is selected,
ChatStateService stores the active group. Downstream components like cometchat-message-header, cometchat-message-list, and cometchat-message-composer automatically subscribe to the change.Advanced Usage
Filtering Groups with Request Builder
Use thegroupsRequestBuilder to filter groups by various criteria:
GroupsRequestBuilder Methods
Selection Modes
Enable single or multiple group selection:Custom Context Menu Options
Provide custom actions for each group:Customization with Templates
Custom Subtitle View
Customize the subtitle section to show member count and group type:Custom Empty and Error States
Provide custom views for empty and error states:Styling with CSS Variables
The CometChatGroups component uses CSS variables for comprehensive theming:Dark Theme Example
Real-Time Features
Automatic Updates
The component automatically updates in real-time for:- Member Events: Join, leave, kick, ban events are reflected immediately
- Group Updates: Name, icon, and description changes
- Connection Recovery: Automatically refreshes the list when connection is re-established
Event Subscriptions
The component subscribes to the following events:Error Handling
Built-in Error Handling
The component includes comprehensive error handling: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.