Skip to main content

Overview

The CometChatGroupMembers component displays a real-time, scrollable list of members belonging to a specific CometChat group. It provides built-in search functionality, allowing you to locate any specific member swiftly. For each member listed, the component displays the member’s name and avatar, along with their scope (owner, admin, moderator, or participant) and online/offline status. The component follows a Service-based Architecture where:
  • GroupMembersService handles SDK request building, pagination, and state management
  • Component manages UI rendering, real-time listeners, and keyboard navigation
  • Templates allow extensive customization of all UI sections

Key Features

  • Real-time Updates: Automatic updates for group member events (join, leave, kick, ban, scope change)
  • Flexible Customization: Extensive template projection for all UI sections
  • Selection Modes: Support for single and multiple member selection
  • Scope Management: Built-in scope change dialog for owners and admins
  • Member Actions: Context menu with kick, ban, and scope change options based on permissions
  • Search Functionality: Built-in search with 300ms debouncing
  • Keyboard Navigation: Full keyboard accessibility with arrow keys and shortcuts (WCAG 2.1 Level AA compliant)
  • Error Handling: Comprehensive error handling with custom error views
Live Preview — default group members list preview. Open in Storybook ↗

Keyboard Accessibility

CometChatGroupMembers 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 members container
  • role="listitem" on each member item
  • aria-label with member name, scope, and status
  • aria-selected indicates selected members
  • Proper tabindex management (roving tabindex pattern)
Screen Reader Support:
  • Announces member details when focused
  • Announces selection state changes
  • Announces member scope (owner/admin/moderator/participant)
  • 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 Status Indicators

Usage Patterns

CometChatGroupMembers supports two usage patterns. The default service-based approach uses ChatStateService to automatically wire the group context. Alternatively, you can pass data explicitly via @Input() bindings.
When a group is selected via ChatStateService, cometchat-group-members automatically subscribes to ChatStateService.activeGroup — no explicit [group] binding required. This is ideal when your app already uses ChatStateService to manage the active conversation.
See the ChatStateService API reference for the full list of signals, observables, and setter methods.
This is the recommended approach for most applications. It reduces boilerplate and keeps components in sync automatically.

Properties

Display Control Properties

Data Configuration Properties

Template Properties

Events

Advanced Usage

Filtering Members with GroupMembersRequestBuilder

Use the groupMemberRequestBuilder to filter members by various criteria:

GroupMembersRequestBuilder Methods

Selection Modes

Enable single or multiple member selection:

Custom Context Menu Options

Provide custom actions for each member:

Scope Change

The component includes built-in scope change functionality. When a group owner or admin clicks the scope indicator on a member, a scope change dialog appears allowing them to change the member’s role. This behavior is controlled by the hideScopeChangeOption input:

Customization with Templates

Custom Subtitle View

Customize the subtitle section to show the member’s join date:

Custom Empty and Error States

Provide custom views for empty and error states:

Styling with CSS Variables

The CometChatGroupMembers component uses CSS variables for comprehensive theming:

Dark Theme Example

Customizing Scope Tags with CSS

Real-Time Features

Automatic Updates

The component automatically updates in real-time for:
  • Member Events: Join, leave, kick, ban events are reflected immediately
  • Scope Changes: Member scope updates appear in real-time
  • 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

Always provide a valid CometChat.Group object to the group input. Fetch the group from the SDK before rendering the component.
Always handle the error event to provide feedback to users when something goes wrong.
The component uses a service-based architecture with GroupMembersService for state management. If you’re using custom templates with external state, ensure proper change detection triggering.
Use hideKickMemberOption, hideBanMemberOption, and hideScopeChangeOption together to create a read-only member list without any management actions.
When using custom context menu options via the options input, 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: