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 Integration Quick Reference
AI Integration Quick Reference
| Field | Value |
|---|---|
| Component | CometChatGroups |
| Package | CometChatUIKitSwift |
| Inherits | UIViewController |
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.onSelectedItemProceed
Fires when the user confirms their selection by tapping the proceed/submit button. Use this to handle the final selection action.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 |
onSelectedItemProceed | Triggered when selection is confirmed | Process selected 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 swipe options for each group. This method allows you to return an array ofCometChatGroupOption based on the group object. These options appear when the user swipes on a group cell.
add(options:)
Dynamically add additional swipe options to groups while preserving the default options. This method lets you return additionalCometChatGroupOption elements that will be appended to the existing options.
Data Manipulation Methods
showJoiningGroupAlert(for:)
Displays an alert dialog when a user attempts to join a password-protected group. This method shows a prompt for the user to enter the group password.| Parameter | Type | Description |
|---|---|---|
group | Group | The password-protected group to join |
hideJoiningGroupAlert(completion:)
Dismisses the joining group alert dialog programmatically. Use this when you need to close the alert without user interaction.| Parameter | Type | Description |
|---|---|---|
completion | (() -> Void)? | Optional closure called after the alert is dismissed |
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.avatarStyle
Customizes the appearance of avatars in group list items.| Type | AvatarStyle |
| Default | AvatarStyle() |
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 |
selectedCellCount
Returns the count of currently selected groups when in selection mode.| Type | Int |
| Default | 0 |
selectionLimit
Sets the maximum number of groups that can be selected in selection mode. When the limit is reached, further selections are disabled.| Type | Int |
| Default | 0 (unlimited) |
selectionMode
Sets the selection mode for multi-select functionality.| Type | SelectionMode |
| Default | .none |
statusIndicatorStyle
Customizes the appearance of group type status indicators.| Type | StatusIndicatorStyle |
| Default | StatusIndicatorStyle() |
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 |
Common Patterns
Public groups only
Joined groups only
Custom empty state with CTA
Hide all chrome — minimal list
Multi-select groups
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