> ## Documentation Index
> Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Group Members

> List of one group's members with scope chips, presence, search, selection, and kick, ban and change-scope actions.

`CometChatGroupMembers` lists the members of one group. Each row shows the member's avatar
with a presence dot, their name — "You" on your own row — and a chip for the owner, admins
and moderators. Rows offer **Scope**, **Ban** and **Kick** to the people allowed to use
them. The list paginates as you scroll, updates in real time and searches the server as you
type in its search field.

![CometChatGroupMembers showing a group's members with their roles](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-overview-group-members.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=0e18b84c87cb2240837441f15e37997c)

***

## Where It Fits

`CometChatGroupMembers` is the screen a group's details open to show who is in it, and the
picker a "mention" or "transfer ownership" flow embeds.

```
your group details screen
        │ group
        ▼
CometChatGroupMembers   ← you are here
        │ onItemClick(member)
        ▼
   your profile screen
```

Both toolkits share one store, so the SwiftUI and UIKit lists can never disagree about
*what* to show or *who* may do what.

***

## Quick Start

> [tab] SwiftUI
>
> ```swift theme={null}
> import CometChatSwiftUI
>
> struct MembersScreen: View {
>     let group: CometChatSDK.Group
>
>     var body: some View {
>         CometChatGroupMembers(
>             group: group,
>             onItemClick: { member in openProfile(of: member) }
>         )
>     }
> }
> ```
>
> That is a working list: it fetches the first 30 members and paginates as you scroll.
> `onItemClick` hands you a `CometChatSDK.GroupMember`.
>
> The list draws a system navigation bar, so it brings its own `NavigationStack`. If your
> screen already has one, pass `embedsNavigationStack: false`. The back button is shown by
> default: it calls `onBack`, or dismisses the screen when you give none. The search field is
> in the bar by default; pass `hideSearch: true` to leave it out.

> [tab] UIKit
>
> ```swift theme={null}
> import CometChatUIKit
>
> let members = CometChatGroupMembers()
>     .set(group: group)
>     .set(onItemClick: { member, indexPath in openProfile(of: member) })
> navigationController?.pushViewController(members, animated: true)
> ```
>
> `CometChatGroupMembers` is a `UIViewController`. Setting the group is what loads the list.
> Present the screen in a `UINavigationController`. The search field is in the navigation item
> by default; `setSearchBoxVisibility(false)` takes it out.
>
> The back control is shown by default. Pushed, the screen has the system's back button; as
> the root of a navigation controller — a modal — it has **Cancel**, which dismisses it.
> With `set(onBack:)` the control calls your handler instead.
>
> ```swift theme={null}
> let members = CometChatGroupMembers(group: group)
> present(UINavigationController(rootViewController: members), animated: true)
> ```
>
> `init(group:groupMembersRequestBuilder:)` is a convenience for `init()` followed by
> `set(group:)`.

***

## Filtering Group Members

> [tab] SwiftUI
>
> ```swift theme={null}
> CometChatGroupMembers(
>     group: group,
>     groupMembersRequestBuilder: GroupMembersRequest.GroupMembersRequestBuilder(guid: group.guid)
>         .set(limit: 50)
>         .set(scopes: ["admin", "moderator"])
> )
> ```
>
> Both `groupMembersRequestBuilder` and `searchRequestBuilder` shape the request from the
> first page; the default is the group's guid, 30 a page.

> [tab] UIKit
>
> ```swift theme={null}
> let members = CometChatGroupMembers()
>     .set(groupMemberRequestBuilder: GroupMembersRequest.GroupMembersRequestBuilder(guid: group.guid)
>         .set(limit: 50)
>         .set(scopes: ["admin", "moderator"]))
>     .set(group: group)
> ```
>
> Both `set(groupMemberRequestBuilder:)` and `set(groupMemberSearchRequestBuilder:)` shape the
> request from the first page; the default is the group's guid, 30 a page.

A search runs 0.6 s after the last keystroke, on the search builder — or on the list
builder when you give none — and shows one page of results in place of the list. Clearing
the field shows the loaded pages again without a request.

> [tab] SwiftUI
>
> `searchKeyword` puts a keyword in the field, which searches. `excludeOwner` hides the
> owner's row.

> [tab] UIKit
>
> `set(excludeOwner:)` hides the owner's row.

***

## Who May Do What

A row's actions depend on who is looking at it.

| You are | Scope | Ban | Kick |
| - | - | - | - |
| the owner | anyone else | anyone else | anyone else |
| an admin | moderators, participants | moderators, participants | moderators, participants |
| a moderator | participants | — | participants |
| a participant | — | — | — |

Nobody is offered an action on their own row, and a moderator cannot ban.

Your scope is read from **your own row**, among the rows on screen. Until that row is
loaded — it is on a later page, or a search has filtered it out — you count as a participant
and no row offers an action. The owner is recognised by the group's owner uid, whatever is
loaded.

> [tab] SwiftUI
>
> Turn an action off for everyone with `disableKick`, `disableBan` or `disableChangeScope`.

> [tab] UIKit
>
> Hide an action for everyone with `hideKickMemberOption`, `hideBanMemberOption` or
> `hideScopeChangeOption`.

***

## Actions and Events

### Callback Methods

> [tab] SwiftUI
>
> | Prop | Signature | When |
> | - | - | - |
> | `onItemClick` | `(GroupMember) -> Void` | a row is tapped |
> | `onItemLongClick` | `(GroupMember) -> Void` | a row is long-pressed |
> | `onSelection` | `(Set<String>) -> Void` | the selection bar's tick is tapped |
> | `onOptionSelected` | `(GroupMember, MenuOption) -> Void` | one of your own row options is chosen |
> | `onSearchTextChange` | `(String) -> Void` | a search runs, or is cleared |
> | `onBack` | `() -> Void` | the back button is tapped |
> | `onError` | `(CometChatError) -> Void` | a page, a search, a kick, a ban or a scope change fails |

> [tab] UIKit
>
> | Setter | Signature | When |
> | - | - | - |
> | `set(onItemClick:)` | `(GroupMember, IndexPath) -> Void` | a row is tapped |
> | `set(onItemLongClick:)` | `(GroupMember, IndexPath) -> Void` | a row is long-pressed |
> | `set(onSelection:)` | `([GroupMember]) -> Void` | the selection bar's tick is tapped |
> | `onSelectedItemProceed` | `(([GroupMember]) -> Void)?` | the same tick, after `onSelection` |
> | `set(onLoad:)` | `([GroupMember]) -> Void` | the listed members change |
> | `set(onEmpty:)` | `() -> Void` | the list becomes empty |
> | `set(onError:)` | `(CometChatException) -> Void` | a page, a search, a kick, a ban or a scope change fails |
> | `set(onBack:)` | `() -> Void` | Cancel or the back button is tapped |
>
> All but `onSelectedItemProceed` are also available on `CometChatGroupMembersDelegate`.

> [!WARNING]
>
> Setting `onItemLongClick` **replaces** the row's menu: a long press calls it instead.
> Setting `onItemClick` while a selection mode is on means a tap calls it and **selects
> nothing** — leave it unset on a picker.

### Kick, ban and change scope

Each permitted action appears twice on a row: as a trailing swipe action and in the
long-press menu.

* **Kick** and **Ban** ask first, in an alert titled "Kick Alice ?" or "Ban Alice ?" —
  "Are You sure you want to kick Alice?" — with a destructive **Yes** and **No**.
* **Scope** opens a sheet listing all three scopes with the member's current one selected.
  A scope you may not give — Admin, when you are a moderator — is listed and disabled.
  **Save** sends the selected scope, also when it is the one the member already has.

Every dialog closes **before** its request is sent: the alert on **Yes**, the sheet on
**Save**. There is no spinner in the sheet.

> [tab] SwiftUI
>
> When an action succeeds the row is removed or updated, and the Kit's other components are
> told through `CometChatEvents`. When it **fails**, the list is left as it was, `onError` is
> called and the error's message is shown as a snackbar — the Kit's toast, which the list
> presents itself from the store's `toast`.

> [tab] UIKit
>
> The actions are a trailing swipe action and an item of the long-press menu, in the order
> Scope, Ban, Kick. Scope presents `CometChatScopeChange` as a sheet.
>
> When an action fails the list is left as it was, `onError` is called and the error's
> message is shown as a snackbar — a `CometChatToast` on this screen; `lastToast` reads the
> last one back.

A failed page or search calls `onError` too. The error state, with **Retry**, is shown only
when nothing is loaded.

### SDK Events (Real-Time, Automatic)

No wiring required — the store listens and the list updates itself.

> [tab] SwiftUI
>
> | Event | Effect |
> | - | - |
> | A member joins or is added | they appear at the top, as a participant |
> | A member leaves, is kicked or is banned | their row is removed |
> | You are banned from the group | the screen stays, your row with it, and a snackbar says "You have been banned from this group." |
> | A user is unbanned elsewhere in the Kit | they are listed at the top, as a participant |
> | A member's scope changes | their chip updates; when it is yours, so do the actions every row offers |
> | A member comes online or goes offline | their presence dot updates |
> | Ownership is transferred elsewhere in the Kit | the "Owner" chip moves |
> | Connection restored | what is on screen is loaded again: the search, with its keyword, when one is showing; otherwise the first page |

> [tab] UIKit
>
> | Event | Effect |
> | - | - |
> | A member joins or is added | they appear at the top, as a participant |
> | A member leaves, is kicked or is banned | their row is removed |
> | You are banned from the group | the screen stays, your row with it, and a snackbar says "You have been banned from this group." |
> | A user is unbanned elsewhere in the Kit | they are listed at the top, as a participant |
> | A member's scope changes | their chip updates; when it is yours, so do the actions every row offers |
> | A member comes online or goes offline | their presence dot updates |
> | Connection restored | what is on screen is loaded again: the search, with its keyword, when one is showing; otherwise the first page |

A member you have blocked, or who has blocked you, shows no presence dot.

***

## Functionality

> [tab] SwiftUI
>
> | Prop | Type | Default |
> | - | - | - |
> | `group` | `CometChatSDK.Group` | required |
> | `store` | `GroupMembersStore?` | a new store |
> | `searchText` | `Binding<String>?` | internal state |
> | `selection` | `Binding<Set<String>>?` | internal state |
> | `groupMembersRequestBuilder` | `GroupMembersRequest.GroupMembersRequestBuilder?` | the group's guid, 30 per page |
> | `searchRequestBuilder` | `GroupMembersRequest.GroupMembersRequestBuilder?` | the list builder |
> | `excludeOwner` | `Bool` | `false` |
> | `style` | `CometChatGroupMembersStyle` | `.init()` |
> | `title` | `String?` | "Members" |
> | `hideToolbar`, `hideBackButton`, `hideSearch`, `hideUserStatus` | `Bool` | `false` |
> | `hideSeparator` | `Bool` | `true` |
> | `disableKick`, `disableBan`, `disableChangeScope` | `Bool` | `false` |
> | `hideLoadingState`, `hideEmptyState`, `hideErrorState` | `Bool` | `false` |
> | `searchPlaceholderText` | `String?` | "Search" |
> | `searchKeyword` | `String?` | `nil` — sets the field, which searches |
> | `selectionMode` | `SelectionMode` | `.disabled` |
> | `furtherSelectionEnabled` | `Bool` | `true` — `false` lets a tap deselect only |
> | `embedsNavigationStack` | `Bool` | `true` |
> | `imageSource` | `any ImageSource` | the shared cached loader |

> [tab] UIKit
>
> | Member | Does |
> | - | - |
> | `set(group:)` | sets the group, which loads the list |
> | `set(excludeOwner:)` | hides the owner's row |
> | `setSearchBoxVisibility(_:)` | shows or hides the search field |
> | `hideKickMemberOption`, `hideBanMemberOption`, `hideScopeChangeOption` | hide an action for everyone |
> | `hideUserStatus` | hides the presence dot |
> | `selectionMode` | `.disabled`, `.single` or `.multiple` |
> | `isFurtherSelectionEnabled` | `false` lets a tap deselect a member and not select another |
> | `clearSelection()` | clears the selection and keeps the mode |
> | `add`, `update`, `insert`, `remove`, `clearList`, `size` | the list operations |
> | `lastToast` | the last snackbar shown |

***

## Custom View Slots

> [tab] SwiftUI
>
> Every slot is available as an initialiser argument and as a modifier that cascades to every
> `CometChatGroupMembers` below it. Supply both and the initialiser argument wins.
>
> ```swift theme={null}
> CometChatGroupMembers(
>     group: group,
>     subtitleView: { member in AnyView(MyMemberSubtitle(member)) },
>     tailView: { member in AnyView(MyMemberBadge(member)) }
> )
> ```
>
> ```swift theme={null}
> .cometChatGroupMemberLeadingView { member in MyMemberAvatar(member) }
> ```
>
> | Slot | Replaces | Modifier |
> | - | - | - |
> | `listItemView` | the whole row | `.cometChatGroupMemberListItemView { member, isSelected in … }` |
> | `leadingView` | the avatar and its presence dot | `.cometChatGroupMemberLeadingView { … }` |
> | `titleView` | the name | `.cometChatGroupMemberTitleView { … }` |
> | `subtitleView` | nothing — it adds a line under the name | `.cometChatGroupMemberSubtitleView { … }` |
> | `tailView` | nothing — it sits beside the scope chip | `.cometChatGroupMemberTailView { … }` |
> | `loadingView` | the shimmer | `.cometChatGroupMembersLoadingView { … }` |
> | `emptyView` | the empty state | `.cometChatGroupMembersEmptyView { … }` |
> | `errorView` | the error state; receives the error | `.cometChatGroupMembersErrorView { error in … }` |
> | `overflowMenu` | nothing — the bar's trailing item | `.cometChatGroupMembersOverflowMenu { … }` |
>
> Slot closures receive a `ChatGroupMember` — the row's value type (`id`, `name`,
> `avatarURL`, `isOnline`, `scope`).
>
> > [!NOTE]
> >
> > The scope chip stays whatever you supply: a custom `tailView` is drawn after it and a
> > custom `subtitleView` under the name. A custom `errorView` replaces the built-in screen
> > and its **Retry**; call `store.retry()` from your own button.

> [tab] UIKit
>
> | Setter | Replaces |
> | - | - |
> | `set(listItemView:)` | the whole row |
> | `set(leadingView:)` | the avatar and its presence dot |
> | `set(titleView:)` | the name |
> | `set(subtitleView:)` | nothing — it adds a line under the name |
> | `set(trailView:)` | nothing — it sits beside the scope chip |
> | `set(loadingView:)`, `set(emptyView:)`, `set(errorView:)` | the three state views |
>
> ```swift theme={null}
> members.set(subtitleView: { member in MyMemberSubtitleView(member) })
> ```
>
> The scope chip stays whatever you supply. To replace the cell class itself, assign
> `listItemCellClass` a subclass of `CometChatGroupMemberListItem`.

***

## Menu Options

> [tab] SwiftUI
>
> ```swift theme={null}
> CometChatGroupMembers(
>     group: group,
>     addOptions: { member in
>         [MenuOption(id: "message", title: "Message", systemImage: "bubble.left")]
>     },
>     onOptionSelected: { member, option in handle(option, for: member) }
> )
> ```
>
> `addOptions` are shown after the built-in actions. A non-empty `options` **replaces** the
> built-in actions, and `addOptions` still follows it.

> [tab] UIKit
>
> ```swift theme={null}
> members.add(options: { group, member in
>     [CometChatGroupMemberOption(id: "message", title: "Message",
>                                 icon: UIImage(systemName: "bubble.left"), backgroundColor: .systemBlue,
>                                 onClick: { member, _, _, _, _ in message(member) })]
> })
> ```
>
> `add(options:)` follows the built-in actions. A non-empty `set(options:)` **replaces** the
> built-in actions, and `add(options:)` still follows it.

***

## Advanced Methods

### Selection

> [tab] SwiftUI
>
> ```swift theme={null}
> @State private var selected: Set<String> = []
>
> CometChatGroupMembers(
>     group: group,
>     selection: $selected,
>     selectionMode: .multiple,
>     onSelection: { uids in mention(uids) }
> )
> ```
>
> Whenever a selection mode is on, the navigation bar is the selection bar: a discard button with
> the number selected beside it — from 0 — and a tick; the title stays. Tapping rows fills
> `selected` — bind `selection` to follow each change — and the tick calls `onSelection` with
> the selected uids. The selection and the mode stay afterwards. The discard button clears the
> selection **and leaves selection mode**; the mode comes back when you pass a different
> `selectionMode`.
>
> In `.single` mode a tap replaces the selection, and a second tap on the selected row
> deselects it. In `.multiple` mode a tap adds a member or removes a selected one. With
> `furtherSelectionEnabled: false` a tap can deselect a member and cannot select another.
> Changing `selectionMode` clears the selection, and a member who leaves the list leaves the
> selection.

> [tab] UIKit
>
> ```swift theme={null}
> let picker = CometChatGroupMembers().set(group: group)
> picker.selectionMode = .multiple
> picker.onSelectedItemProceed = { picked in mention(picked) }
> ```
>
> Whenever a selection mode is on, the navigation bar is the selection bar: a discard button with
> the number selected beside it — from 0 — and a tick; the title stays. The tick calls
> `onSelection` and then `onSelectedItemProceed`, each with the selected members in the order
> they were picked; neither is called while rows are being tapped. The selection and the mode
> stay afterwards. The discard button clears the selection **and sets `selectionMode` back to
> `.disabled`**; `clearSelection()` clears the selection and keeps the mode.
>
> In `.single` mode a tap replaces the selection, and a second tap on the selected row
> deselects it. With `isFurtherSelectionEnabled = false` a tap can deselect a member and
> cannot select another. Setting `selectionMode` starts with nothing selected.

### Store Access

> [tab] SwiftUI
>
> ```swift theme={null}
> @State private var store = GroupMembersStore()
>
> CometChatGroupMembers(group: group, store: store)
>     .toolbar { Button("Reload") { Task { await store.refreshList() } } }
> ```
>
> `GroupMembersStore` also exposes `search(_:)`, `fetchGroupMembers()`, `retry()`, `kick(_:)`,
> `ban(_:)`, `changeScope(_:to:)`, `options(for:)`, `assignableScopes(for:)`, `viewerScope`,
> `toast` — the snackbar waiting to be shown — and the list operations `addItem`, `insertItem`,
> `removeItem`, `updateItem` and `clearItems`.

> [tab] UIKit
>
> The view controller's store is `groupMembersStore`.

### Subclassing

> [tab] SwiftUI
>
> `CometChatGroupMembers` is a `View` struct. Customise it with its slots, modifiers and style.

> [tab] UIKit
>
> These override points are `open`:
>
> | Override | Purpose |
> | - | - |
> | `defaultSetup()` | title and initial configuration |
> | `setupStyle()` | applies the style |
> | `configureTailView(groupMember:)` | builds the scope chip; return `nil` for none |
> | `configureMenu(groupMember:)` | builds the row's swipe actions, which are also its menu |
> | `onRemoveMemberSelected(for:)`, `onBanMemberSelected(for:)` | present the confirmation |
> | `tickButtonTapped()`, `crossButtonTapped()` | the selection bar's tick and discard |
> | `didTapBackButton()` | Cancel, or the back button |
> | `onRetryTapped()`, `onSearch(text:)` | the error state's Retry; the search field |
> | `fetchData()`, `reloadData()` | load the next page; re-render |
>
> ```swift theme={null}
> final class MemberPicker: CometChatGroupMembers {
>     override func defaultSetup() {
>         super.defaultSetup()
>         selectionMode = .multiple
>     }
>
>     // A picker removes nobody.
>     override func configureMenu(groupMember: GroupMember) -> [UIContextualAction] { [] }
> }
> ```

***

## Style

> [tab] SwiftUI
>
> ```swift theme={null}
> var style = CometChatGroupMembersStyle()
> style.backgroundColor = Color(.systemGroupedBackground)
> style.itemTitleColor = .indigo
> style.scopeChipOwnerBackgroundColor = .orange
> style.avatarStyle = .init(size: 48)
>
> CometChatGroupMembers(group: group, style: style)
> ```
>
> Unset properties fall through to the theme, so a style carries only what you change.
>
> | Property | Styles |
> | - | - |
> | `backgroundColor`, `strokeColor`, `strokeWidth`, `cornerRadius` | the screen |
> | `navigationBarBackgroundColor`, `navigationBarItemsTintColor` | the navigation bar and its buttons |
> | `itemTitleColor`, `itemTitleFont`, `itemBackgroundColor` | the row |
> | `scopeChipOwner…` | the owner's chip |
> | `scopeChipBackgroundColor`, `scopeChipTextColor`, `itemScopeTextFont` | admins' and moderators' chips |
> | `scopeChipStrokeColor`, `scopeChipStrokeWidth` | the border on an admin's chip |
> | `scopeChipCornerRadius`, `scopeChipPadding…` | the chip's shape — a capsule by default |
> | `avatarStyle`, `statusIndicatorStyle` | the avatar and the presence dot |
> | `checkBox…` | the selection checkbox |
> | `itemSelectedBackgroundColor` | a selected row's fill — none by default |
> | `separatorColor`, `separatorHeight` | the separator, shown with `hideSeparator: false` |
> | `emptyStateStyle`, `errorStateStyle`, `loadingStateSurfaceColor` | the three state views |
> | `scopeChangeStyle` | the change-scope sheet |
>
> > [!NOTE]
> >
> > 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.
>
> The title, the back button's glyph and the search field belong to the system's navigation
> bar; the style properties for them have no effect.

> [tab] UIKit
>
> ```swift theme={null}
> let style = GroupMembersStyle()
> style.backgroundColor = .systemGroupedBackground
> style.listItemTitleTextColor = .systemIndigo
> style.retryButtonCornerRadius = 20
> members.set(style: style)
>
> CometChatGroupMembers.style = style        // every new instance
> ```
>
> The scope chip takes its colours from the theme; override `configureTailView(groupMember:)`
> to draw your own. `CometChatScopeChange.style` — a `ScopeChangeStyle` — styles the
> change-scope sheet.
>
> > [!NOTE]
> >
> > On iOS 26 the navigation bar is Liquid Glass and is left to the system unless you set
> > `navigationBarTintColor`. Below iOS 26, or with Reduce Transparency on, it is filled with
> > the list's background.

***

## Next Steps

> [card] [Groups](https://www.cometchat.com/docs/ui-kit/ios/v6/groups.md)
>
> The list of groups a member belongs to

> [card] [Users](https://www.cometchat.com/docs/ui-kit/ios/v6/users.md)
>
> The directory of users to add as members

> [card] [Group Chat](https://www.cometchat.com/docs/ui-kit/ios/v6/guide-group-chat.md)
>
> Create, join and manage groups

> [card] [Component Styling](https://www.cometchat.com/docs/ui-kit/ios/v6/component-styling.md)
>
> Style every component


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.