Skip to main content

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 container
  • role="listitem" on each group item
  • aria-label with group name, type, and member count
  • aria-selected indicates selected groups
  • Proper tabindex management (roving tabindex pattern)
Screen Reader Support:
  • Announces group details when focused
  • Announces selection state changes
  • Announces group type (public/private/password)
  • Semantic HTML structure
Focus Management:
  • Visible focus indicators (2px border) meeting WCAG contrast requirements
  • Focus restoration after interactions
  • Roving tabindex for efficient keyboard navigation
WCAG 2.1 Compliance:
  • ✅ 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.
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.The component auto-updates ChatStateService (via setActiveGroup) only when (itemClick) is not observed. For this service-driven mode, leave (itemClick) unbound so the automatic selection stays enabled.
This is the recommended approach. Selecting a group automatically updates all downstream message components.
Binding (itemClick) suppresses the automatic ChatStateService selection. If you observe (itemClick), you must drive selection yourself — either call this.chatState.setActiveGroup(group) inside your handler, or pass [group]="activeGroup" into the downstream components (see the “Using Props” tab).

Advanced Usage

Filtering Groups with Request Builder

Use the groupsRequestBuilder 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

Use groupsRequestBuilder to limit the initial fetch size for better performance. The default limit is 30 groups per page.
Always handle the error event to provide feedback to users when something goes wrong.
The component uses OnPush change detection strategy for optimal performance. If you’re using custom templates with external state, ensure proper change detection triggering.
Use hideGroupType to simplify the UI if your application only uses one type of group.
When using custom context menu options, ensure the onClick handlers are properly bound to avoid this context issues. Use arrow functions.

Complete Example

Here’s a comprehensive example combining multiple features: