CometChatGroups component displays a searchable list of all available groups. It shows group names, avatars, member counts, and group type indicators (public/private/password-protected). Users can browse, join, and interact with group conversations.

AI Agent Component Spec
AI Agent Component Spec
Where It Fits
CometChatGroups displays all available groups for browsing and joining. It’s typically used as a standalone screen or within a tab view controller.

Minimal Render

Filtering
UseGroupsRequest.GroupsRequestBuilder to filter which groups appear in the list. The builder pattern allows chaining multiple filter conditions.
Filter Recipes
| Recipe | Code |
|---|---|
| Joined groups only | .set(joinedOnly: true) |
| Search by name | .set(searchKeyword: "design") |
| Filter by tags | .set(tags: ["engineering", "marketing"]) |
| Include tag info | .set(withTags: true) |
| Limit results | GroupsRequestBuilder(limit: 20) |
Actions and Events
Callback Props
onItemClick
Fires when a user taps on a group in the list. Use this to open the group chat.onItemLongClick
Fires when a user long-presses on a group. Use this to show additional options.onBack
Fires when the back button is pressed.onSelection
Fires when groups are selected in selection mode.onError
Fires when an error occurs while loading groups.onEmpty
Fires when the group list is empty.onLoad
Fires when groups are successfully loaded.Actions Reference
| Method | Description | Example |
|---|---|---|
set(onItemClick:) | Triggered when a group is tapped | Open group chat |
set(onItemLongClick:) | Triggered on long press | Show options menu |
set(onBack:) | Triggered when back button is pressed | Custom navigation |
set(onSelection:) | Triggered in selection mode | Multi-select groups |
set(onError:) | Triggered when an error occurs | Show error alert |
set(onEmpty:) | Triggered when list is empty | Show empty state |
set(onLoad:) | Triggered when groups load | Analytics tracking |
Global UI Events
| Event | Fires when | Payload |
|---|---|---|
ccGroupCreated | A group is created | Group |
ccGroupDeleted | A group is deleted | Group |
ccGroupMemberJoined | A user joins a group | User, Group |
ccGroupMemberLeft | A user leaves a group | User, Group |
SDK Events (Real-Time, Automatic)
| SDK Listener | Internal behavior |
|---|---|
onGroupMemberJoined | Updates member count |
onGroupMemberLeft | Updates member count |
onGroupMemberKicked | Updates member count |
onGroupMemberBanned | Updates member count |
onGroupMemberUnbanned | Updates group info |
onGroupMemberScopeChanged | Updates member scope |
onMemberAddedToGroup | Updates member count |
Custom View Slots
| Slot | Signature | Replaces |
|---|---|---|
listItemView | (Group) -> UIView | Entire group row |
leadingView | (Group) -> UIView | Avatar / left section |
titleView | (Group?) -> UIView | Name / title text |
subtitleView | (Group?) -> UIView | Member count / subtitle |
trailingView | (Group?) -> UIView | Right side content |
emptyStateView | () -> UIView | Empty state display |
errorStateView | () -> UIView | Error state display |
loadingStateView | () -> UIView | Loading state display |
listItemView
Replace the entire group row with a custom design.
CustomGroupCell as a custom UIView:
leadingView
Customize the leading view (avatar area) of a group cell.
CustomLeadingView as a custom UIView:
titleView
Customize the title view of a group cell.
CustomTitleView as a custom UIView:
subtitleView
Customize the subtitle area below the group name.
CustomSubtitleView as a custom UIView:
trailingView
Customize the trailing view (right side) of a group cell.
CustomTrailView as a custom UIView:
loadingStateView
Customize the loading state view displayed while data is being fetched.errorStateView
Customize the error state view displayed when an error occurs.emptyStateView
Customize the empty state view displayed when no groups are available.Options
set(options:)
Define custom options for each group. This method allows you to return an array ofCometChatGroupOption based on the group object.
add(options:)
Dynamically add options to groups. This method lets you return additionalCometChatGroupOption elements.
Styling
Style Hierarchy
- Global styles (
CometChatGroups.style) apply to all instances - Instance styles override global for specific instances
Global Level Styling
Instance Level Styling
Key Style Properties
| Property | Type | Default | Description |
|---|---|---|---|
backgroundColor | UIColor | CometChatTheme.backgroundColor01 | Background color |
titleColor | UIColor | CometChatTheme.textColorPrimary | Navigation title color |
titleFont | UIFont | CometChatTypography.Heading4.medium | Navigation title font |
listItemTitleTextColor | UIColor | CometChatTheme.textColorPrimary | Group name color |
listItemTitleFont | UIFont | CometChatTypography.Heading4.medium | Group name font |
listItemSubTitleTextColor | UIColor | CometChatTheme.textColorSecondary | Member count color |
listItemSubTitleFont | UIFont | CometChatTypography.Body.regular | Member count font |
listItemBackground | UIColor | .clear | List item background |
privateGroupBadgeColor | UIColor | CometChatTheme.iconColorSecondary | Private group badge color |
passwordGroupBadgeColor | UIColor | CometChatTheme.iconColorSecondary | Password group badge color |
Customization Matrix
| What to change | Where | Property/API | Example |
|---|---|---|---|
| Background color | Style | backgroundColor | UIColor.systemBackground |
| Title appearance | Style | titleColor, titleFont | Custom colors and fonts |
| List item look | Style | listItemBackground | UIColor.white |
| Avatar appearance | Style | avatarStyle | AvatarStyle() with custom radius |
| Group type badges | Style | privateGroupBadgeColor | Custom badge colors |
| Hide search | Property | hideSearch | groups.hideSearch = true |
| Hide group type | Property | hideGroupType | groups.hideGroupType = true |
| Custom row | View Slot | set(listItemView:) | See Custom View Slots |
Props
All props are optional. Sorted alphabetically.groupsRequestBuilder
Custom request builder for filtering groups.| Type | GroupsRequest.GroupsRequestBuilder? |
| Default | nil |
hideBackButton
Hides the back button in the navigation bar.| Type | Bool |
| Default | false |
hideErrorView
Hides the error state view.| Type | Bool |
| Default | false |
hideGroupType
Hides the public/private/password group type icons.| Type | Bool |
| Default | false |
hideLoadingState
Hides the loading state indicator.| Type | Bool |
| Default | false |
hideNavigationBar
Hides the entire navigation bar.| Type | Bool |
| Default | false |
hideSearch
Hides the search bar.| Type | Bool |
| Default | false |
hideSectionHeader
Hides the alphabetical section headers.| Type | Bool |
| Default | false |
searchRequestBuilder
Custom request builder for search functionality.| Type | GroupsRequest.GroupsRequestBuilder? |
| Default | nil |
selectionMode
Sets the selection mode for multi-select functionality.| Type | SelectionMode |
| Default | .none |
Events
| Event | Payload | Fires when |
|---|---|---|
ccGroupCreated | Group | A group is created |
ccGroupDeleted | Group | A group is deleted |
ccGroupMemberJoined | User, Group | A user joins a group |
ccGroupMemberLeft | User, Group | A user leaves a group |
Troubleshooting
| Issue | Solution |
|---|---|
| Empty group list | Ensure SDK is initialized and user is logged in |
| Groups not updating in real-time | Check SDK connection and group listeners |
| Search not working | Verify hideSearch is not set to true |
| Group type icons not showing | Check that hideGroupType is not set to true |
| Custom views not appearing | Ensure custom view has proper constraints |
Related Components
- Messages - Display messages in a group
- Conversations - List all conversations
- Users - List all users
- Group Members - Manage group members
- Groups With Messages - Combined groups and messages view