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

RecipeCode
Joined groups onlynew CometChat.GroupsRequestBuilder().joinedOnly(true)
Limit to 10 per pagenew CometChat.GroupsRequestBuilder().setLimit(10)
Search by keywordnew CometChat.GroupsRequestBuilder().setSearchKeyword("design")
Filter by tagsnew CometChat.GroupsRequestBuilder().setTags(["vip"])
With tags datanew CometChat.GroupsRequestBuilder().withTags(true)
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.
EventFires whenPayload
ccGroupCreatedThe logged-in user creates a groupCometChat.Group
ccGroupDeletedThe logged-in user deletes a groupCometChat.Group
ccGroupLeftThe logged-in user leaves a group{ leftGroup: CometChat.Group }
ccGroupMemberScopeChangedThe logged-in user changes scope of another memberIGroupMemberScopeChanged
ccGroupMemberBannedThe logged-in user bans a group memberIGroupMemberKickedBanned
ccGroupMemberKickedThe logged-in user kicks a group memberIGroupMemberKickedBanned
ccGroupMemberUnbannedThe logged-in user unbans a group memberIGroupMemberUnBanned
ccGroupMemberJoinedThe logged-in user joins a groupIGroupMemberJoined
ccGroupMemberAddedThe logged-in user adds members to a groupIGroupMemberAdded
ccOwnershipChangedThe logged-in user transfers group ownershipIOwnershipChanged

SDK Events (Real-Time, Automatic)

The component listens to these SDK events internally. No manual attachment needed unless additional side effects are required.
SDK ListenerInternal behavior
onGroupMemberJoinedUpdates member count when a user joins
onGroupMemberLeftUpdates member count when a user leaves
onMemberAddedToGroupUpdates member count when members are added
onGroupMemberKickedUpdates member count when a member is kicked
onGroupMemberBannedUpdates member count when a member is banned
onGroupMemberScopeChangedUpdates scope when a member’s scope changes

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.
SlotSignatureReplaces
ItemView(group: CometChat.Group) => JSX.ElementEntire list item row
LeadingView(group: CometChat.Group) => JSX.ElementAvatar / left section
TitleView(group: CometChat.Group) => JSX.ElementName / title text
SubtitleView(group: CometChat.Group) => JSX.ElementMember count subtitle
TrailingView(group: CometChat.Group) => JSX.ElementRight section
LoadingView() => JSX.ElementLoading spinner
EmptyView() => JSX.ElementEmpty state
ErrorView() => JSX.ElementError state
AppBarOptions() => JSX.ElementHeader bar options

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

PropertyTypeDescription
containerStyleViewStyleStyle for the root container
headerStyleViewStyleStyle for the header section
titleStyleTextStyleStyle for the header title
itemStyleobjectStyle for list items (includes avatarStyle, titleStyle, subtitleStyle)
searchStyleobjectStyle for the search bar

Props

All props are optional unless noted.

EmptyView

Custom component displayed when there are no groups.
Type() => JSX.Element
DefaultBuilt-in empty state

ErrorView

Custom component displayed when an error occurs.
Type() => JSX.Element
DefaultBuilt-in error state

groupsRequestBuilder

Controls which groups load and in what order.
TypeCometChat.GroupsRequestBuilder
DefaultSDK default (30 per page)
Pass the builder instance, not the result of .build().

groupTypeVisibility

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

hideError

Hides the error state view.
Typeboolean
Defaultfalse

hideHeader

Hides the entire header bar.
Typeboolean
Defaultfalse

hideLoadingState

Hides the loading state while fetching groups.
Typeboolean
Defaultfalse

hideSearch

Hides the search bar.
Typeboolean
Defaultfalse

hideSubmitButton

Hides the submit button when selection mode is enabled.
Typeboolean
Defaulttrue

ItemView

Custom renderer for the entire list item row.
Type(group: CometChat.Group) => JSX.Element
DefaultBuilt-in list item

LeadingView

Custom renderer for the avatar / left section.
Type(group: CometChat.Group) => JSX.Element
DefaultBuilt-in avatar

LoadingView

Custom component displayed during the loading state.
Type() => JSX.Element
DefaultBuilt-in loading indicator

onBack

Callback fired when the back button is pressed.
Type() => void
Defaultundefined

onEmpty

Callback fired when the group list is empty.
Type() => void
Defaultundefined

onError

Callback fired when the component encounters an error.
Type(error: CometChat.CometChatException) => void
Defaultundefined

onItemLongPress

Callback fired when a group row is long-pressed.
Type(group: CometChat.Group) => void
Defaultundefined

onItemPress

Callback fired when a group row is tapped.
Type(group: CometChat.Group) => void
Defaultundefined

onLoad

Callback fired when groups are loaded.
Type(list: CometChat.GroupMember[]) => void
Defaultundefined

onSelection

Callback fired when groups are selected/deselected. Requires selectionMode to be set.
Type(list: Array<CometChat.Group>) => void
Defaultundefined

onSubmit

Callback fired when the submit button is pressed. Requires selectionMode to be set.
Type(list: Array<CometChat.Group>) => void
Defaultundefined

searchKeyword

Pre-fills the search and filters the group list.
Typestring
Default""

searchRequestBuilder

Request builder with search parameters to fetch groups.
TypeCometChat.GroupsRequestBuilder
Defaultundefined

selectionMode

Enables single or multi-select mode on list items.
Type"single" | "multiple" | "none"
Default"none"

showBackButton

Shows the back button in the header.
Typeboolean
Defaultfalse

searchPlaceholderText

Placeholder text for the search input.
Typestring
Default"Search"

privateGroupIcon

Custom icon for private groups.
TypeImageSourcePropType
DefaultBuilt-in icon

passwordGroupIcon

Custom icon for password-protected groups.
TypeImageSourcePropType
DefaultBuilt-in icon

addOptions

Function to append additional menu items to the default context menu.
Type(group: CometChat.Group) => MenuItemInterface[]
Defaultundefined

options

Function to replace the default context menu items entirely.
Type(group: CometChat.Group) => MenuItemInterface[]
Defaultundefined

SubtitleView

Custom renderer for the member count subtitle.
Type(group: CometChat.Group) => JSX.Element
DefaultBuilt-in subtitle

TitleView

Custom renderer for the name / title text.
Type(group: CometChat.Group) => JSX.Element
DefaultBuilt-in title

TrailingView

Custom renderer for the right section.
Type(group: CometChat.Group) => JSX.Element
DefaultBuilt-in trailing view

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