CometChatGroups lists the groups in your app. Each row shows the group’s avatar with a
badge for private and password-protected groups, its name and its member count. A tap
opens a group the user is in and joins a public one first. The list paginates as you scroll,
updates in real time and searches the server as you type in its search field.

Where It Fits
CometChatGroups is the screen a user opens to find a group to chat in, or the picker a
“share to groups” flow embeds. It hands you the selected Group through onItemClick; open
your message screen with it.
Quick Start
- SwiftUI
- UIKit
NavigationStack. If your screen already has one, pass embedsNavigationStack: false.
The search field is in the bar by default; pass hideSearchBox: true to leave it out.onItemClick hands you a CometChatSDK.Group: one the user is a member of, or a
password-protected one they have not joined yet — check hasJoined.
Prerequisites: the Kit initialised with CometChatSession.initialize, a user logged in, and
the package added. See Getting Started.
What a Tap Does
Outside selection mode a tap depends on the group.
If the join fails
onError is called and nothing else happens: there is no alert and no
error screen. A successful join is announced on the Kit’s event bus as a member-joined event,
so the Kit’s other components follow.
Filtering Groups
Two builders: one for browsing, one used while a search is active.- SwiftUI
- UIKit
Both builders are used from the first page. With no search builder, a search runs on your
list builder with the keyword added, and the keyword is taken off again afterwards. Giving
the list a different list builder after it has loaded replaces the list with that builder’s
first page.
Filter Recipes
Actions and Events
Callback Methods
- SwiftUI
- UIKit
onLoad is called with the loaded list — not a search’s result — each time it changes.
onError is called for every failure. The error state is shown when nothing is loaded, and
also when the next page fails with rows on screen — it takes their place. A failed
refresh or search with rows on screen leaves them there. Retry reloads the first page. A
failed join is reported to onError and shows nothing.
SDK Events (Real-Time, Automatic)
No wiring required — the store listens and the list updates itself.
The first page is also fetched again, and replaces the list when it arrives, on
pull-to-refresh. The list does not reload when the screen re-appears. Removing the last
group leaves a blank list: the empty state is for the server answering with no groups, or a
search finding none.
Functionality
- SwiftUI
- UIKit
hideToolbar hides the navigation bar, and the search field with it. hideToolbarSeparator,
passwordGroupIcon and privateGroupIcon draw nothing; set the badge’s glyphs through
itemStyle.statusIndicatorStyle.Custom View Slots
- SwiftUI
- UIKit
Every slot is available as an initialiser argument and as a modifier that cascades to every
CometChatGroups below it. Supply both and the initialiser argument wins.Slot closures receive a
ChatGroup — the row’s value type (id, name, type,
membersCount, hasJoined, scope, ownerUID).Menu Options
The list has no options of its own. Give it some and each row shows them twice: as trailing swipe actions and as a long-press menu.- SwiftUI
- UIKit
options come first and the added options after them; both lists are shown.
Common Patterns
Join a password-protected group
A password group comes toonItemClick like any other: check hasJoined, ask for the
password and join through the store.
- SwiftUI
- UIKit
join(_:password:) returns the joined group, or nil after calling onError —
a wrong password is reported there and nowhere else.
Scope buttons under the search field
- SwiftUI
- UIKit
.cometChatSearchScopes(_:selection:) puts scope buttons under the search field, in the
navigation bar, as a New Chat screen switches between Users and Groups. The rows scroll under
the field and the buttons with the bar’s soft edge, and the large title stays sharp.The buttons show whether or not the field is being searched, and they don’t filter the
search: the list only reports the selection, and what it means is up to you. The modifier
applies to every list under it, so when your screen swaps one list for the other, the
buttons stay in the bar with the right one selected.
Advanced Methods
Selection
- SwiftUI
- UIKit
selected.onItemClick it is called as well, before the selection changes. onSelection is called
with the whole selection on every change. In .single mode a second tap on the selected
row deselects it. A .multiple selection has no limit.
Once something is selected the navigation bar shows the count with a cross and a tick. The
tick calls onSelectedItemProceed with the selected groups and leaves the selection and the
mode as they are. The cross clears the selection; the mode stays on, so the next tap selects
again.
Store Access
- SwiftUI
- UIKit
GroupsStore also exposes join(_:password:), search(_:), fetchGroups(), retry() and
the list operations addItem, insertItem, removeItem, updateItem, moveItemToTop and
clearItems.Subclassing
- SwiftUI
- UIKit
CometChatGroups is a View struct. Customise it with its slots, modifiers and style.Style
- SwiftUI
- UIKit
On iOS 26 the navigation bar is Liquid Glass and the Kit leaves it to the system. Below
iOS 26, or with Reduce Transparency on, the bar is filled with the list’s background.
Setting
navigationBarBackgroundColor fills it everywhere.Next Steps
Group Members
List and manage the members of a group
Message List
Show the messages of the group a tap opens
Group Chat
Create, join and manage groups
Component Styling
Style every component