Skip to main content

Where It Fits

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

Minimal Render


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. A separate searchRequestBuilder can be passed to filter the search list independently from the main list. Refer to GroupsRequestBuilder for the full builder API.

Actions and Events

Callback Props

onItemPress

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

onItemLongPress

Fires when a group item is long-pressed, allowing additional actions like leave or delete.

onSelection

Fires when groups are selected/deselected in selection mode. Requires selectionMode to be set.

onEmpty

Fires when the group list fetch returns zero results.

onError

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

onLoad

Fires when groups are successfully fetched and loaded.

Global UI Events

CometChatUIEventHandler 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.

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.

SubtitleView

Replace the member count subtitle.

AppBarOptions

Custom view for the header bar options.

options

Custom context menu actions for each group item.

Common Patterns

Custom empty state with CTA

Joined groups only

Multi-select with submit

Hide all chrome — minimal list


Styling

The component uses the theme system from CometChatThemeProvider. Pass a style prop to customize the appearance.

Style Properties


Props

All props are optional unless noted.

EmptyView

Custom component displayed when there are no groups.

ErrorView

Custom component displayed when an error occurs.

groupsRequestBuilder

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

groupTypeVisibility

Shows/hides the group type icon (public/private/password).

hideError

Hides the error state view.

hideHeader

Hides the entire header bar.

hideLoadingState

Hides the loading state while fetching groups.

hideSearch

Hides the search bar.

hideSubmitButton

Hides the submit button when selection mode is enabled.

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.

onBack

Callback fired when the back button is pressed.

onEmpty

Callback fired when the group list is empty.

onError

Callback fired when the component encounters an error.

onItemLongPress

Callback fired when a group row is long-pressed.

onItemPress

Callback fired when a group row is tapped.

onLoad

Callback fired when groups are loaded.

onSelection

Callback fired when groups are selected/deselected. Requires selectionMode to be set.

onSubmit

Callback fired when the submit button is pressed. Requires selectionMode to be set.

searchKeyword

Pre-fills the search and filters the group list.

searchRequestBuilder

Request builder with search parameters to fetch groups.

selectionMode

Enables single or multi-select mode on list items.

showBackButton

Shows the back button in the header.

searchPlaceholderText

Placeholder text for the search input.

privateGroupIcon

Custom icon for private groups.

passwordGroupIcon

Custom icon for password-protected groups.

addOptions

Function to append additional menu items to the default context menu.

options

Function to replace the default context menu items entirely.

SubtitleView

Custom renderer for the member count subtitle.

TitleView

Custom renderer for the name / title text.

TrailingView

Custom renderer for the right section.

Next Steps

Group Members

View and manage members of a group

Conversations

Display and manage the list of recent chats

Message List

Display the full chat interface after selecting a group

Component Styling

Customize the appearance of UI Kit components