> ## 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.

# Conversations

> Scrollable list of the logged-in user's one-on-one and group conversations, with last messages, unread counts, typing indicators, presence, filters and item callbacks.

`CometChatConversations` displays a list of all conversations (one-on-one and group chats)
for the currently logged-in user. It shows the last message, unread count, typing
indicators and user presence, and updates in real time.

![CometChatConversations showing recent chats with avatars, last-message previews, receipts, timestamps and unread badges](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-overview-conversations.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=5cf84e8ef71a971a359efd0260259506)

***

## Where It Fits

`CometChatConversations` is the entry screen of a chat experience: the list a user lands
on, from which they open a conversation.

```
CometChatConversations   ← you are here
        │ onItemClick(conversation)
        ▼
   your message screen
```

Both toolkits read from the same store, so the SwiftUI and UIKit lists can never disagree
about *what* to show.

***

## Quick Start

> [tab] SwiftUI
>
> ```swift theme={null}
> import CometChatSwiftUI
>
> struct ChatsScreen: View {
>     var body: some View {
>         CometChatConversations(
>             onItemClick: { conversation in openChat(conversation) }
>         )
>     }
> }
> ```
>
> That is a working list: it fetches the first page, paginates as you scroll, and updates
> live as messages arrive. `onItemClick` hands you a `CometChatSDK.Conversation`.
>
> The list draws a system large-title navigation bar, so it brings its own `NavigationStack`.
> If your screen already has one, pass `embedsNavigationStack: false`.
>
> Set-up: [Getting Started](https://www.cometchat.com/docs/ui-kit/ios/v6/getting-started-swiftui.md).

> [tab] UIKit
>
> ```swift theme={null}
> import CometChatUIKit
> import CometChatSDK
>
> final class ChatsViewController: UIViewController, @MainActor CometChatConversationsDelegate {
>     func showConversations() {
>         let conversations = CometChatConversations()
>         conversations.delegate = self
>         navigationController?.pushViewController(conversations, animated: true)
>     }
>
>     func onItemClick(conversation: Conversation, indexPath: IndexPath) {
>         openChat(conversation)
>     }
> }
> ```
>
> That is a working list: it fetches the first page, paginates as you scroll, and updates
> live as messages arrive.
>
> `CometChatConversations` inherits from `CometChatListBase`, which supplies the navigation
> bar, search bar, and the loading, empty and error states. Anything on `CometChatListBase`
> is available here too.
>
> Set-up: [Getting Started](https://www.cometchat.com/docs/ui-kit/ios/v6/getting-started-uikit.md).

***

## Filtering Conversations

> [tab] SwiftUI
>
> ```swift theme={null}
> CometChatConversations(
>     conversationsRequestBuilder: {
>         ConversationRequest.ConversationRequestBuilder(limit: 30)
>             .setConversationType(conversationType: .group)
>     }
> )
> ```

> [tab] UIKit
>
> Pass a `ConversationRequestBuilder` through the store to filter what is fetched.
>
> ```swift theme={null}
> let store = ConversationsStore(
>     conversationsRequestBuilder: {
>         ConversationRequest.ConversationRequestBuilder(limit: 30)
>             .setConversationType(conversationType: .group)
>     }
> )
> let conversations = CometChatConversations(conversationsStore: store)
> ```
>
> Or hand the controller a builder; it takes effect on the next fetch:
>
> ```swift theme={null}
> conversations.set(conversationsRequestBuilder:
>     ConversationRequest.ConversationRequestBuilder(limit: 30).setConversationType(conversationType: .user))
> ```

> [!NOTE]
>
> The builder closure is called **fresh for every fetch**, so return a new builder each
> time rather than capturing one instance. Reusing one instance across pages produces
> undefined paging behaviour.

### Filter Recipes

| Goal | Builder |
| - | - |
| Groups only | `.setConversationType(conversationType: .group)` |
| One-on-one only | `.setConversationType(conversationType: .user)` |
| Larger pages | `.set(limit: 50)` |
| Unread only | `.set(unread: true)` |
| Include blocked users | `.include(blockedUsers: true)` |

***

## Actions and Events

### Callback Methods

> [tab] SwiftUI
>
> | Prop | Signature |
> | - | - |
> | `onItemClick` | `(Conversation) -> Void` |
> | `onItemLongClick` | `(Conversation) -> Void` |
> | `onSelection` | `(Set<String>) -> Void` |
> | `onOptionSelected` | `(Conversation, MenuOption) -> Void` |
> | `onSearchClick` | `() -> Void` |
> | `onBack` | `() -> Void` |
> | `onLoad` | `([Conversation]) -> Void` |
> | `onEmpty` | `() -> Void` |
> | `onError` | `(CometChatError) -> Void` |

> [tab] UIKit
>
> Set on the instance, fluently. These take precedence over the delegate.
>
> | Setter | Signature |
> | - | - |
> | `set(onItemClick:)` | `(Conversation, IndexPath) -> Void` |
> | `set(onItemLongClick:)` | `(Conversation, IndexPath) -> Void` |
> | `set(onSelection:)` | `([Conversation]) -> Void` |
> | `set(onSearchClick:)` | `() -> Void` |
> | `set(onError:)` | `(CometChatException) -> Void` |
> | `set(onBack:)` | `() -> Void` |
> | `set(onLoad:)` | `([Conversation]) -> Void` |
> | `set(onEmpty:)` | `() -> Void` |
>
> ```swift theme={null}
> conversations.set(onItemClick: { conversation, _ in openChat(conversation) })
> ```
>
> `CometChatConversationsDelegate` is the alternative to closures, and the idiomatic
> choice for a coordinator. Every method is optional.
>
> ```swift theme={null}
> @objc public protocol CometChatConversationsDelegate: AnyObject {
>     @objc optional func onItemClick(conversation: Conversation, indexPath: IndexPath)
>     @objc optional func onItemLongClick(conversation: Conversation, indexPath: IndexPath)
>     @objc optional func onSelection(conversations: [Conversation])
>     @objc optional func onError(error: NSError)
>     @objc optional func onLoad(conversations: [Conversation])
>     @objc optional func onEmpty()
>     @objc optional func onBack()
> }
> ```

> [!WARNING]
>
> `onItemLongClick` fires **only when no context menu is configured**. iOS gives the
> long-press gesture to the context menu, so the two are mutually exclusive. In selection
> mode it does not fire.

### Global Events

The list listens on the Kit event bus, whoever emits the events.

> [tab] SwiftUI
>
> A `.conversationDeleted` event removes the row and a `.conversationUpdated` event merges it.
> Subscribe from any view:
>
> ```swift theme={null}
> .onCometChatConversationDeleted { conversation in print("deleted", conversation.conversationId ?? "") }
> ```
>
> See [Events](https://www.cometchat.com/docs/ui-kit/ios/v6/events.md) for the whole bus.

> [tab] UIKit
>
> `ccConversationDeleted` removes the row and `ccUpdateConversation` merges it. Listen from
> anywhere with `CometChatConversationEvents.addListener(_:_:)` and a
> `CometChatConversationEventListener`. See [Events](https://www.cometchat.com/docs/ui-kit/ios/v6/events.md).

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

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

| Event | Effect |
| - | - |
| Message received | conversation moves to top, unread count increments |
| Message read | receipt updates |
| Typing started / ended | subtitle shows the typing indicator |
| User online / offline | presence dot updates |
| Message edited / deleted | last-message line updates |
| Connection lost / restored | connection notice appears, then a refresh |

***

## Navigation and Search

> [tab] SwiftUI
>
> The screen draws a **system large-title navigation bar** — "Chats", with the search field in
> the bar under the large title. That gives you Liquid Glass on iOS 26 and an opaque bar below
> it. The field is the bar's own, so it stays on screen while the list scrolls, and rows
> passing under it fade into the bar. The screen supplies its own `NavigationStack` so it works
> on its own; pass `embedsNavigationStack: false` if you already have one.

> [tab] UIKit
>
> The controller sets up large titles on the host's `UINavigationController` and the search
> field in `navigationItem.searchController`. Push it onto a navigation controller — on its own
> it has no bar to draw into. Leaving `navigationBarTintColor` unset is deliberate: the bar is
> then the system's, which means Liquid Glass on iOS 26 and an opaque bar below it.
>
> Pulling the list down reloads its first page; the rows stay on screen until it lands.

The search field is a **button**. Touching it calls `onSearchClick` and nothing else — the
list does not filter itself. The field opens a search screen: wire `onSearchClick` to yours.

> [tab] SwiftUI
>
> ```swift theme={null}
> CometChatConversations(onSearchClick: { showSearch() })
> ```

> [tab] UIKit
>
> ```swift theme={null}
> conversations.set(onSearchClick: { showSearch() })
> ```

***

## Pinning Conversations

Pin and unpin appear in the swipe actions and in the long-press menu. Pinning happens at
once; unpinning asks first. A pinned row stays above the rest and keeps its place when new
messages arrive elsewhere.

The affordance is hidden when the app does not have the pin feature enabled server-side, or
when an administrator pinned the row — the server refuses to let a user unpin that one, so
offering it would only produce an error. Delete is hidden on that row as well, for the same
reason: the row is the administrator's, and it comes back pinned whatever the user deletes.

> [tab] SwiftUI
>
> `hidePinOption` hides the Pin / Unpin affordance, and `hideDeleteOption` hides Delete from
> the swipe actions and the long-press menu.

> [tab] UIKit
>
> `hidePinConversationOption` and `enablePinConversation` hide the pin affordance, and
> `hideDeleteConversationOption` hides Delete. `enablePinConversation` is on by default; set it
> to `false` to turn pinning off. Deleting asks first, and a full swipe does not delete — you
> have to tap. Override `isDeleteOptionShown(for:)` to change the rule for the administrator's
> row.

***

## Functionality

> [tab] SwiftUI
>
> | Prop | Type | Default |
> | - | - | - |
> | `store` | `ConversationsStore?` | `nil` — one is created for you |
> | `pageSize` | `Int` | `30` |
> | `policy` | `ConversationsPolicy` | `ConversationsPolicy()` |
> | `conversationsRequestBuilder` | `(() -> ConversationRequest.ConversationRequestBuilder)?` | `nil` |
> | `searchText` | `Binding<String>?` | `nil` — the component owns it |
> | `selection` | `Binding<Set<String>>?` | `nil` |
> | `selectionMode` | `SelectionMode` | `.disabled` |
> | `title` | `String?` | `nil` — a localised default is used |
> | `style` | `CometChatConversationsStyle` | `CometChatConversationsStyle()` |
> | `dateFormat` | `DateFormatter?` | `nil` |
> | `dateTimeFormatter` | `(any CometChatDateTimeFormatter)?` | `nil` — a relative formatter is used |
> | `textFormatters` | `[any CometChatTextFormatter]?` | `nil` |
> | `mentionAllLabelId`, `mentionAllLabel` | `String?` | `nil` |
> | `imageSource` | `any ImageSource` | a shared cached loader |
> | `embedsNavigationStack` | `Bool` | `true` |
> | `hideBackIcon`, `hideSeparator` | `Bool` | `true` |
> | `hideToolbar`, `hideSearchBox`, `hideSearchEndIcon`, `hideUserStatus`, `hideGroupType`, `hideReceipts`, `hideDeleteOption`, `hidePinOption` | `Bool` | `false` |
> | `hideLoadingState`, `hideEmptyState`, `hideErrorState` | `Bool` | `false` |
> | `disableSoundForMessages` | `Bool` | `false` |
> | `customSoundForMessages` | `URL?` | `nil` |
>
> `dateFormat` formats the timestamp on each row and takes precedence over
> `dateTimeFormatter`. `hideSeparator` is `true` by default: pass `false` to draw the separator
> and `separatorColor` / `separatorHeight` to style it.
>
> `cometChatConversationsHidden(_:)` takes an option set and **unions** with the `hide*`
> arguments — neither cancels the other.
>
> ```swift theme={null}
> CometChatConversations().cometChatConversationsHidden([.searchBox, .receipts])
> ```

> [tab] UIKit
>
> | Property | Type | Default |
> | - | - | - |
> | `delegate` | `CometChatConversationsDelegate?` | `nil` |
> | `conversationsStore` | `ConversationsStore` | a store created for you |
> | `listItemCellClass` | `AnyClass` | `CometChatConversationListItem.self` |
> | `selectionMode` | `SelectionMode` | `.disabled` |
> | `style` | `ConversationsStyle` | `ConversationsStyle()` |
> | `hideBackButton`, `hideSeparator` | `Bool` | `true` |
> | `hideNavigationBar`, `hideSearch`, `hideReceipts`, `hideUserStatus`, `hideGroupType` | `Bool` | `false` |
> | `hideDeleteConversationOption`, `hidePinConversationOption` | `Bool` | `false` |
> | `enablePinConversation` | `Bool` | `true` |
> | `disableTyping` | `Bool` | `false` |
> | `hideLoadingState`, `hideErrorView` | `Bool` | `false` |
> | `disableSoundForMessages` | `Bool` | `false` |
> | `customSoundForMessages` | `URL?` | `nil` |
>
> `hideBackButton` hides the back button in the navigation bar, `hideReceipts` hides delivery
> and read receipts on each row, `hideUserStatus` hides the online presence indicator and
> `hideGroupType` hides the group-type icon. `customSoundForMessages` is a sound file played on
> incoming messages. `hideSeparator` is `true` by default: set it to `false` to draw the
> separator.

***

## Custom View Slots

> [tab] SwiftUI
>
> Every slot is available **two ways**: as an initialiser argument, and as a modifier that
> cascades to every `CometChatConversations` below it in the hierarchy.
>
> > [!NOTE]
> >
> > Supply both and the **initialiser argument wins**. Full order: initialiser argument,
> > then modifier, then theme, then the Kit default. This is the usual answer to "why
> > didn't my change apply?".
>
> For comparison, the list with no overrides at all:
>
> ![Default Conversations list with the built-in row: avatar, name, last message, timestamp and unread badge](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/override-none.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=52632d9b876614d3adc2ff672fa4795f)
>
> **`itemView`** replaces the entire row. It receives the conversation and whether it is
> selected.
>
> ```swift theme={null}
> CometChatConversations(
>     itemView: { conversation, isSelected in
>         AnyView(MyRow(conversation: conversation, selected: isSelected))
>     }
> )
> ```
>
> ![Conversations list where itemView replaces the entire row with a custom card layout](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/override-itemView.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=a93a74ff97fdd37115133446b6ccf714)
>
> **`leadingView`** replaces the avatar.
>
> ```swift theme={null}
> .cometChatConversationLeadingView { conversation in MyAvatar(conversation) }
> ```
>
> ![Conversations list with a custom leading view replacing the default avatar](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/override-leadingView.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=a9f321591a5efcf584d013f1c01b5581)
>
> **`titleView`** replaces the name line.
>
> ```swift theme={null}
> .cometChatConversationTitleView { conversation in Text(conversation.title).bold() }
> ```
>
> ![Conversations list with a custom title view replacing the default name line](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/override-titleView.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=5b8e09e271b5bb639bf3a841403c9a35)
>
> **`subtitleView`** replaces the last-message line.
>
> ```swift theme={null}
> .cometChatConversationSubtitleView { conversation in MySubtitle(conversation) }
> ```
>
> ![Conversations list with a custom subtitle view replacing the last-message line](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/override-subtitleView.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=5d7fdfbda402f7be62cd41c51d540cdb)
>
> **`trailingView`** replaces the date, badge and receipt column.
>
> ```swift theme={null}
> .cometChatConversationTrailingView { conversation in
>     MyUnreadPill(count: conversation.unreadCount)
> }
> ```
>
> ![Conversations list with a custom trailing view replacing the date and unread badge column](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/override-trailingView.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=26177991a1a37ef6f988204e904653f3)
>
> **State views.** `errorView` receives a `retry` closure — call it to re-attempt the fetch.
>
> ```swift theme={null}
> CometChatConversations(
>     loadingView: { AnyView(MySpinner()) },
>     emptyView:   { AnyView(MyEmptyState()) },
>     errorView:   { retry in AnyView(MyErrorState(onRetry: retry)) }
> )
> ```
>
> ![Conversations list showing a custom loading view](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/override-loadingView.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=64924fdc83ef0bb79d0f874d38d5e8fe)
>
> loadingView
>
> ![Conversations list showing a custom empty state](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/override-emptyView.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=b5ea7cce2b5d91c821166daaee66a906)
>
> emptyView
>
> ![Conversations list showing a custom error state with a retry button](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/override-errorView.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=cc0b7243346f62bcfbc30805e5c91628)
>
> errorView
>
> **`overflowMenu`** adds your own toolbar menu.
>
> ```swift theme={null}
> CometChatConversations(overflowMenu: { AnyView(MyToolbarMenu()) })
> ```

> [tab] UIKit
>
> Each slot replaces one region of the row and receives the SDK `Conversation`.
>
> The stock row, for comparison:
>
> ![Default UIKit Conversations list with the built-in cell](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/uikit-stock.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=e30742b920e808a1588ea95e163faab7)
>
> **`listItemView`** replaces the entire row.
>
> ```swift theme={null}
> conversations.set(listItemView: { conversation in
>     MyConversationRow(conversation: conversation)
> })
> ```
>
> **`leadingView`** replaces the avatar.
>
> ```swift theme={null}
> conversations.set(leadingView: { conversation in
>     MyAvatarView(conversation: conversation)
> })
> ```
>
> **`titleView`** replaces the name line.
>
> ```swift theme={null}
> conversations.set(titleView: { conversation in
>     MyTitleView(text: conversation.lastMessage?.sender?.name)
> })
> ```
>
> **`subtitleView`** replaces the last-message line.
>
> ```swift theme={null}
> conversations.set(subtitleView: { conversation in
>     MySubtitleView(conversation: conversation)
> })
> ```
>
> **`trailView`** replaces the date, badge and receipt column.
>
> ```swift theme={null}
> conversations.set(trailView: { conversation in
>     MyUnreadPill(for: conversation)
> })
> ```
>
> **State views.**
>
> ```swift theme={null}
> conversations
>     .set(loadingView: MySpinner())
>     .set(emptyView: MyEmptyState())
>     .set(errorView: MyErrorState())
> ```
>
> ![UIKit Conversations showing a custom loading view](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/uikit-loadingView.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=14d20bdf123a7754e34a39b6076a36ec)
>
> loadingView
>
> ![UIKit Conversations showing a custom empty state](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/uikit-emptyView.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=cc6a7f48b780e1bb97d9e1a20b173c72)
>
> emptyView
>
> ![UIKit Conversations showing a custom error state](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/uikit-errorView.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=81a58eb539de84bba3a3348cf22f8327)
>
> errorView
>
> Setting a custom state view after the view has loaded requires `renderCurrentState()` —
> otherwise the state was already rendered with the previous view and your replacement stays
> hidden.
>
> **Replacing the cell.** For full control over layout and reuse, supply your own cell class
> instead of slots.
>
> ```swift theme={null}
> conversations.listItemCellClass = MyConversationCell.self
> ```
>
> Subclass `CometChatConversationListItem` and override its one `configure` — the method the list
> calls for every row — to keep the built-in row and change part of it:
>
> ```swift theme={null}
> final class MyConversationCell: CometChatConversationListItem {
>     override func configure(with conversation: ChatConversation,
>                             style: ConversationsStyle,
>                             theme: CometChatUIKitTheme,
>                             hideReceipts: Bool,
>                             hideUserStatus: Bool,
>                             hideGroupType: Bool,
>                             selectionMode: SelectionMode,
>                             isSelected: Bool,
>                             dateTimeFormatter: ((Date) -> String)?) {
>         super.configure(with: conversation, style: style, theme: theme, hideReceipts: hideReceipts,
>                         hideUserStatus: hideUserStatus, hideGroupType: hideGroupType,
>                         selectionMode: selectionMode, isSelected: isSelected,
>                         dateTimeFormatter: dateTimeFormatter)
>         titleLabel.textColor = .systemIndigo
>     }
> }
> ```
>
> ![UIKit Conversations list rendering a custom UITableViewCell subclass](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/uikit-customCell.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=f387d185932e7d75804c503ffe220598)
>
> > [!NOTE]
> >
> > Clear custom subviews and cancel in-flight image loads in `prepareForReuse()`, or the
> > wrong content appears on the next row during fast scrolling. The built-in cell does
> > this; a subclass must too.

***

## Menu Options

Give the list options and each row shows them twice: as trailing swipe actions and as a
long-press menu. `options` **replaces** the built-in options; `addOptions` **appends** to
them. Reach for `addOptions` unless you want the defaults gone. The two built-ins are Delete
and Pin / Unpin.

> [tab] SwiftUI
>
> ```swift theme={null}
> CometChatConversations(
>     addOptions: { conversation in
>         [MenuOption(id: "pin", title: "Pin", systemImage: "pin", isDestructive: false)]
>     }
> )
> ```
>
> ![Conversations context menu showing only custom actions, replacing the built-in ones](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/override-options.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=2174a6ebbc6e80c97128a3fd579332cd)
>
> options — defaults replaced
>
> ![Conversations context menu showing custom actions appended below the built-in ones](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/override-addOptions.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=fe744eb31f2a312facea4d8fdb3461c3)
>
> addOptions — appended to defaults
>
> A context menu claims the long-press gesture, so `onItemLongClick` fires only when no menu is
> configured. Use `onOptionSelected` to react to a menu choice.

> [tab] UIKit
>
> `set(options:)` and `set(addOptions:)` take `[CometChatConversationOption]`.
>
> ```swift theme={null}
> conversations.set(addOptions: { conversation, indexPath in
>     [CometChatConversationOption(id: "archive", title: "Archive",
>                                  icon: UIImage(systemName: "archivebox")) { conversation, _ in
>         archive(conversation)
>     }]
> })
> ```

***

## Common Patterns

### Open a chat on tap

> [tab] SwiftUI
>
> ```swift theme={null}
> @State private var path: [Conversation] = []
>
> NavigationStack(path: $path) {
>     CometChatConversations(onItemClick: { path.append($0) })
>         .navigationDestination(for: Conversation.self) { MessagesScreen(conversation: $0) }
> }
> ```

> [tab] UIKit
>
> A coordinator owns the navigation and is the list's delegate. Keep a strong reference to
> it — the list holds its delegate weakly.
>
> ```swift theme={null}
> @MainActor
> final class ChatsFlow: NSObject, @MainActor CometChatConversationsDelegate {
>     private let navigationController: UINavigationController
>
>     init(navigationController: UINavigationController) {
>         self.navigationController = navigationController
>     }
>
>     func start() {
>         let conversations = CometChatConversations()
>         conversations.delegate = self
>         navigationController.pushViewController(conversations, animated: false)
>     }
>
>     func onItemClick(conversation: Conversation, indexPath: IndexPath) {
>         let messages = MessagesViewController(conversation: conversation)
>         navigationController.pushViewController(messages, animated: true)
>     }
> }
> ```

### Multi-select with a custom toolbar

> [tab] SwiftUI
>
> ```swift theme={null}
> @State private var selected: Set<String> = []
>
> CometChatConversations(
>     selection: $selected,
>     overflowMenu: { AnyView(Button("Delete \(selected.count)") { deleteAll(selected) }) },
>     selectionMode: .multiple
> )
> ```

> [tab] UIKit
>
> The UIKit list shows its selection controls in the navigation bar. To act on the selection,
> use `set(onSelection:)` — see Selection under Advanced Methods.

### Groups only, with your own empty state

> [tab] SwiftUI
>
> ```swift theme={null}
> CometChatConversations(
>     conversationsRequestBuilder: {
>         ConversationRequest.ConversationRequestBuilder(limit: 30).setConversationType(conversationType: .group)
>     },
>     emptyView: { AnyView(NoGroupsYet(onCreate: createGroup)) }
> )
> ```

> [tab] UIKit
>
> ```swift theme={null}
> let store = ConversationsStore(conversationsRequestBuilder: {
>     ConversationRequest.ConversationRequestBuilder(limit: 30).setConversationType(conversationType: .group)
> })
> let conversations = CometChatConversations(conversationsStore: store)
> conversations.set(emptyView: NoGroupsYetView())
> conversations.renderCurrentState()
> ```

### Preview without credentials

> [tab] SwiftUI
>
> ```swift theme={null}
> #Preview {
>     CometChatConversations(store: .init(seeded: .populated(entries, hasMore: false)))
> }
> ```

> [tab] UIKit
>
> ```swift theme={null}
> let vc = CometChatConversations(
>     conversationsStore: .init(seeded: .populated(entries, hasMore: false))
> )
> ```

***

## Date Time Formatter

Row timestamps use a relative format by default — "now", "12:04", "Yesterday", "9 Oct 25".

> [tab] SwiftUI
>
> There are two ways to change it. `dateFormat` replaces it wholesale and wins over everything
> else:
>
> ```swift theme={null}
> let formatter = DateFormatter()
> formatter.dateFormat = "HH:mm"
>
> CometChatConversations(dateFormat: formatter)
> ```
>
> `dateTimeFormatter` changes one bucket at a time — today's time, "Yesterday", the weekday
> inside a week, a date beyond it. Implement only the methods you care about; the rest fall
> back to the default:
>
> ```swift theme={null}
> struct WeekdayOnly: CometChatDateTimeFormatter {
>     func otherDays(_ date: Date) -> String? {
>         date.formatted(.dateTime.weekday(.wide))
>     }
> }
> ```
>
> ```swift theme={null}
> CometChatConversations(dateTimeFormatter: WeekdayOnly())
> ```

> [tab] UIKit
>
> Replace it wholesale with `datePattern`. `dateFormat` (a `DateFormatter`) wins over
> `datePattern` when both are set.
>
> ```swift theme={null}
> conversations.set(datePattern: { conversation in
>     myFormatter.string(from: conversation.updatedAt)
> })
> ```

***

## Mention Configuration

A row's last-message line runs the text-formatter chain, as the message list does. The
default is one `CometChatMentionsFormatter`, so `<@uid:…>` reads as `@Name` (from the
message's `mentionedUsers`) and `<@all:…>` as `@all`. A mention of someone else draws in the
theme's primary colour, a mention of you or of everyone in its warning colour.

> [tab] SwiftUI
>
> `style.mentionTextColor` and `style.mentionBackgroundColor` restyle the first.
>
> ```swift theme={null}
> CometChatConversations(
>     mentionAllLabelId: "all",
>     mentionAllLabel: "everyone"
> )
> ```
>
> `textFormatters` **replaces** the chain: pass your own formatters to change what the line
> says, or `[]` to show the raw text. `mentionAllLabelId` / `mentionAllLabel` configure the
> default formatter only.

> [tab] UIKit
>
> ```swift theme={null}
> let conversations = CometChatConversations()
> conversations.setMentionAllLabel("all", "everyone")
> conversations.setMentionsStyle(textColor: .systemTeal,
>                                backgroundColor: UIColor.systemTeal.withAlphaComponent(0.2))
> ```
>
> `set(textFormatters:)` **replaces** the chain: pass your own formatters to change what the line
> says, or `[]` to show the raw text. `setMentionAllLabel` configures the default formatter only.

***

## Advanced Methods

### Selection

While selection is on, tapping a row only toggles it: `onItemClick` does not fire, so a tap
handler cannot push a screen out from under someone who is picking rows.

> [tab] SwiftUI
>
> `searchText` and `selection` are `Binding`s, so your view owns them:
>
> ```swift theme={null}
> @State private var search = ""
> @State private var selected: Set<String> = []
>
> CometChatConversations(
>     searchText: $search,
>     selection: $selected,
>     selectionMode: .multiple
> )
> ```
>
> Selection reports in two places, and the difference matters:
>
> | Callback | When it fires |
> | - | - |
> | the `selection` binding | on every toggle — pass one to see each change |
> | `onSelection` | **once**, when the user taps submit in the selection toolbar, with the whole set |
>
> ```swift theme={null}
> @State private var selection: Set<String> = []
>
> CometChatConversations(
>     selection: $selection,
>     selectionMode: .multiple,
>     onSelection: { picked in forward(picked) }  // submit, once
> )
> ```

> [tab] UIKit
>
> `onSelection` fires **once**, from the submit button in the navigation bar, with everything
> picked — not on every tap.
>
> ```swift theme={null}
> conversations.selectionMode = .multiple
> conversations.set(onSelection: { picked in forward(picked) })  // submit, once
> ```

### Store Access

> [tab] SwiftUI
>
> The store is the data source. It is injectable and non-`final`. Seed it to render fixed state
> with no session:
>
> ```swift theme={null}
> CometChatConversations(store: .init(seeded: .populated(entries, hasMore: false)))
> ```
>
> A seeded store performs no fetching, searching or pagination.
>
> The view has no imperative methods; ask the list to return to the top through the store, not
> the view — a SwiftUI view is a value and has nothing to call a method on.
>
> ```swift theme={null}
> @State private var store = ConversationsStore()
>
> CometChatConversations(store: store)
> Button("Jump to top") { store.scrollToTop() }
> ```
>
> The store already scrolls to top by itself when a new message arrives; this is the same
> mechanism exposed for your own use.

> [tab] UIKit
>
> `conversationsStore` is the data source. It is injectable, and non-`final` so it can be
> subclassed. Seed it to render fixed state with no session:
>
> ```swift theme={null}
> CometChatConversations(conversationsStore: .init(seeded: .populated(entries, hasMore: false)))
> ```
>
> A seeded store performs no fetching, searching or pagination.
>
> | Method | Purpose |
> | - | - |
> | `reloadData()` | re-render from current store state |
> | `renderCurrentState()` | re-apply the loading/empty/error view after changing one |
> | `getConversationList()` | every row, as SDK `Conversation`s |
> | `getSelectedConversations()` | the rows picked, as SDK `Conversation`s |
> | `size()` | how many rows there are |
> | `selectConversation(id:)` | select a row without a tap |
> | `clearSelection()` | drop the whole selection |
> | `insert(conversation:)` `update(conversation:)` `remove(conversation:)` | mutate the list directly |
> | `clearList()` | empty it |
> | `refreshConversations()` | re-fetch, keeping the rows on screen |
> | `refreshStyle()` | re-read the style and redraw |
> | `connect()` | start the store's realtime listeners — the store owns them, and `disconnect()` does nothing |

### Subclassing

> [tab] SwiftUI
>
> `CometChatConversations` is a `View` struct, so behaviour that a UIKit app would achieve by
> subclassing is supplied as values instead. `ConversationsPolicy` carries the behaviour
> hooks — which custom messages update their conversation, and threaded-message detection.
>
> ```swift theme={null}
> CometChatConversations(
>     policy: ConversationsPolicy(
>         shouldUpdateForCustomMessage: { message in message.type == "meeting" },
>         isThreadedMessage: { $0.parentMessageId > 0 }
>     )
> )
> ```

> [tab] UIKit
>
> These override points are `open`:
>
> | Method | Override to |
> | - | - |
> | `defaultSetup()` | change initial configuration |
> | `setupStyle()` | apply your own appearance |
> | `showEmptyView()` `showErrorView()` | replace state presentation |
> | `reloadData()` | intercept refreshes |
> | `configureMenu(for:indexPath:)` | build the context menu yourself |
> | `updateNavigationBarTitleWithCount(_:)` | react to the selection count — the bar already shows it beside the cross |
>
> ```swift theme={null}
> final class AddMembersViewController: CometChatConversations {
>     override func setupStyle() {
>         super.setupStyle()
>         view.backgroundColor = .systemGroupedBackground
>     }
> }
> ```
>
> ```swift theme={null}
> final class AddMembersViewController: CometChatConversations {
>     override func defaultSetup() {
>         super.defaultSetup()
>         selectionMode = .multiple
>         hideDeleteConversationOption = true
>     }
>
>     override func setupStyle() {
>         super.setupStyle()
>         view.backgroundColor = .systemGroupedBackground
>     }
> }
> ```

***

## Style

> [tab] SwiftUI
>
> ```
> initialiser argument  >  modifier  >  theme  >  Kit default
> ```
>
> Style properties are optional and resolved at render, so anything left unset falls
> through to the theme instead of being frozen at construction.
>
> Global level:
>
> ```swift theme={null}
> MyApp()
>     .cometChatTheme(brandTheme)     // see Theming for how brandTheme is built
> ```
>
> Instance level:
>
> ```swift theme={null}
> CometChatConversations(
>     style: CometChatConversationsStyle(
>         titleColor: .purple,
>         itemStyle: ConversationListItemStyle(titleFont: .title3)
>     )
> )
> ```
>
> | Property | Affects |
> | - | - |
> | `backgroundColor` | screen background |
> | `titleColor` `titleFont` | toolbar title |
> | `itemStyle` | the row — name, subtitle, date, badge, avatar, receipt |
> | `searchBackgroundColor` `searchTextColor` `searchPlaceholderColor` | no effect; the search field is the system bar's and keeps its look |
> | `searchCornerRadius` `cornerRadius` | shape |
> | `showToolbarSeparator` `toolbarSeparatorColor` | toolbar rule |
> | `emptyStateStyle` `errorStateStyle` | state views |
>
> | Need | Use |
> | - | - |
> | Brand colour everywhere | `.cometChatTheme(_:)` at the app root |
> | One screen looks different | `style:` argument |
> | One region of the row | a slot argument or modifier |
> | Whole row layout | `itemView` |
> | Behaviour, not appearance | `policy:` |

> [tab] UIKit
>
> ```
> instance style  >  theme  >  Kit default
> ```
>
> A style property left unset falls through to the theme rather than freezing a value
> when the component is created.
>
> Global level:
>
> ```swift theme={null}
> CometChatUIKitTheme.shared.setBrandColor(.systemIndigo)
> CometChatUIKitTheme.shared.textPrimary = .label
> ```
>
> One style for every instance:
>
> ```swift theme={null}
> let house = ConversationsStyle()
> house.largeTitleColor = .label
> house.tableViewSeparator = .separator
> ConversationsStyle.style = house
> ```
>
> ![UIKit Conversations after setting a brand colour on the shared theme](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-uikitBrand.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=6a70acc67abc49182bbf5553cdb11831)
>
> Instance level:
>
> ```swift theme={null}
> let style = ConversationsStyle()
> style.titleColor = .purple
> style.itemTitleFont = .preferredFont(forTextStyle: .headline)
> conversations.set(style: style)
> ```
>
> | Property | Type | Affects |
> | - | - | - |
> | `backgroundColor` | `UIColor?` | screen background |
> | `titleColor` `titleFont` | `UIColor?` `UIFont?` | navigation title |
> | `itemTitleColor` `itemTitleFont` | `UIColor?` `UIFont?` | conversation name |
> | `itemSubtitleColor` `itemSubtitleFont` | `UIColor?` `UIFont?` | last-message line |
> | `dateColor` `dateFont` | `UIColor?` `UIFont?` | timestamp |
> | `badgeBackgroundColor` `badgeTextColor` | `UIColor?` | unread badge |
> | `avatarBackgroundColor` `avatarTextColor` | `UIColor?` | avatar initials |
> | `separatorColor` `tableViewSeparator` | `UIColor?` | row separator (hidden until `hideSeparator = false`) |
> | `largeTitleColor` `largeTitleFont` | `UIColor?` `UIFont?` | the large navigation title |
> | `navigationBarTintColor` | `UIColor?` | **leave unset** for the system bar, which is Liquid Glass on iOS 26 |
> | `messageTypeImageTint` | `UIColor?` | the glyph in front of the preview |
> | `receiptSentTint` … `receiptFailedTint` | `UIColor?` | the four receipt states |
> | `typingIndicatorTextColor` `…Font` | `UIColor?` `UIFont?` | the typing line |
> | `pinIconTint` | `UIColor?` | the pin glyph beside the date |
> | `onlineStatusColor` `privateGroupImageBackgroundColor` `passwordGroupImageBackgroundColor` | `UIColor?` | the avatar's badge |
> | `listItemSelectedImage` `listItemDeSelectedImage` | `UIImage?` | selection, in place of a checkmark |
> | `pinActionBackgroundColor` `deleteActionBackgroundColor` | `UIColor?` | the swipe actions |
> | `searchBarTextColor` `searchBarPlaceholderTextColor` … | `UIColor?` | the bar's search field |
>
> | Need | Use |
> | - | - |
> | Brand colour everywhere | `CometChatUIKitTheme.shared.setBrandColor(_:)` |
> | One screen looks different | `set(style:)` |
> | One region of the row | a view slot |
> | Whole row layout | `listItemCellClass` |
> | Behaviour, not appearance | subclass and override |

***

## Next Steps

> [card] [Users](https://www.cometchat.com/docs/ui-kit/ios/v6/users.md)
>
> List the users a person can start a chat with

> [card] [Message List](https://www.cometchat.com/docs/ui-kit/ios/v6/message-list.md)
>
> Show the messages of the conversation a tap opens

> [card] [Theming](https://www.cometchat.com/docs/ui-kit/ios/v6/theming.md)
>
> Colour, typography and shape tokens

> [card] [Overview](https://www.cometchat.com/docs/ui-kit/ios/v6/overview.md)
>
> Choose a toolkit and see what the Kit includes


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