Skip to main content

Where It Fits

CometChatGroups is a directory list component. It renders available groups and emits the selected CometChat.Group via onItemClick. Wire it to CometChatMessageHeader, CometChatMessageList, and CometChatMessageComposer to build a group chat layout.

Minimal Render

Root CSS class: .cometchat-groups

Filtering Groups

Pass a CometChat.GroupsRequestBuilder to groupsRequestBuilder. Pass the builder instance — not the result of .build().

Filter Recipes

Default page size is 30. The component uses infinite scroll — the next page loads as the user scrolls to the bottom. The searchRequestBuilder prop accepts a separate GroupsRequestBuilder for filtering when the search bar is active.
Refer to GroupsRequestBuilder for the full builder API.

Actions and Events

Callback Props

onItemClick

Fires when a group row is tapped. Primary navigation hook — set the active group and render the message view.

onSelect

Fires when a group is checked/unchecked in multi-select mode. Requires selectionMode to be set.

onError

Fires on internal errors (network failure, auth issue, SDK exception).

Global UI Events

CometChatGroupEvents emits events subscribable from anywhere in the application. Subscribe in a useEffect and unsubscribe on cleanup.

SDK Events (Real-Time, Automatic)

The component listens to these SDK events internally. No manual attachment needed unless additional side effects are required.
In React 18 StrictMode, useEffect runs twice on mount in development. The component handles listener cleanup internally, but any additional listeners added alongside the component need cleanup in the useEffect return function to avoid duplicate event handling.

Custom View Slots

Each slot replaces a section of the default UI. Slots that accept a group parameter receive the CometChat.Group object for that row.

itemView

Replace the entire list item row. Default:
Customized:

titleView

Replace the name / title text. Group type badge inline example.

subtitleView

Replace the member count subtitle text. Default:
Customized:

leadingView

Replace the avatar / left section. Joined status badge example.

trailingView

Replace the right section. Join status button example.

headerView

Replace the entire header bar.

options

Replace the context menu / hover actions on each group item.

Common Patterns

Custom empty state with CTA

Hide all chrome — minimal list

Joined groups only


CSS Architecture

The component uses CSS custom properties (design tokens) defined in @cometchat/chat-uikit-react/css-variables.css. The cascade:
  1. Global tokens (e.g., --cometchat-primary-color, --cometchat-background-color-01) are set on the .cometchat root wrapper.
  2. Component CSS (.cometchat-groups) consumes these tokens via var() with fallback values.
  3. Overrides target .cometchat-groups descendant selectors in a global stylesheet.
To scope overrides to a single instance when multiple CometChatGroups exist on the same page, wrap the component in a container and scope selectors:

Key Selectors

Example: Brand-themed groups

Customization Matrix


Props

All props are optional unless noted otherwise.

activeGroup

Highlights the specified group in the list. Must be a reference-equal object from the SDK; a manually constructed object will not match.

emptyView

Custom component displayed when there are no groups.

errorView

Custom component displayed when an error occurs. Hidden when hideError={true}.

groupsRequestBuilder

Controls which groups load and in what order. Pass the builder instance, not the result of .build().

headerView

Custom component rendered as the entire header bar.

hideError

Hides the default and custom error views. Also suppresses errorView if set.

hideGroupType

Hides the group type icon (public/private/password).

hideSearch

Hides the default search bar.

itemView

Custom renderer for the entire list item row.

leadingView

Custom renderer for the avatar / left section.

loadingView

Custom component displayed during the loading state.

onError

Callback fired when the component encounters an error.

onItemClick

Callback fired when a group row is clicked.

onSelect

Callback fired when a group is selected/deselected. Requires selectionMode to be set.

options

Custom context menu / hover actions for each group item.

searchRequestBuilder

Controls filtering when the search bar is active.

selectionMode

Enables single or multi-select checkboxes on list items.
Must pair with onSelect to capture selections.

showScrollbar

Shows the scrollbar in the group list.

subtitleView

Custom renderer for the member count subtitle text.

titleView

Custom renderer for the name / title text.

trailingView

Custom renderer for the right section.

Events

All events are RxJS Subject instances. Subscribe with .subscribe(), unsubscribe with the returned subscription’s .unsubscribe().

CSS Selectors