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

# View Slots

> Replace one region of a CometChat iOS UI Kit v6 component — leading view, title, subtitle, trailing view, or the whole row — in SwiftUI and UIKit.

View slots swap out one part of a component's row — the avatar area, the title, the subtitle,
the trailing column, or the entire row — while the component keeps its data, paging,
selection and real-time updates.

***

## Available View Slots

Section names are concepts; the two toolkits spell some slots differently on purpose.

| Slot | Region | SwiftUI | UIKit |
| - | - | - | - |
| Leading view | the avatar area | `leadingView` | `set(leadingView:)` |
| Title view | the name line | `titleView` | `set(titleView:)` |
| Subtitle view | the second line — the last message, presence | `subtitleView` | `set(subtitleView:)` |
| Trailing view | the date, badge and receipt column | `trailingView` | `set(trailView:)` (some screens: `set(trailingView:)`) |
| Item view | the entire row | `itemView` | `set(listItemView:)` |

> [!WARNING]
>
> An item view replaces the whole row, so the other row slots are not asked.

***

## How It Works

> [tab] SwiftUI
>
> Every slot is available **two ways**: as an initialiser argument returning `AnyView`, and as
> a modifier with a `@ViewBuilder` closure that cascades to every instance of that component
> below it in the hierarchy.
>
> ```swift theme={null}
> CometChatConversations()
>     .cometChatConversationLeadingView { conversation in MyAvatar(conversation) }
>     .cometChatConversationTrailingView { conversation in
>         MyUnreadPill(count: conversation.unreadCount)
>     }
> ```
>
> The closure receives the Kit's value type — `ChatConversation`, `ChatUser`, `ChatGroup`,
> `ChatGroupMember` — not an SDK object. Supply both an argument and a modifier and **the
> argument wins**.

> [tab] UIKit
>
> Each setter takes a closure that returns a `UIView` for a row, and receives the SDK object:
>
> ```swift theme={null}
> conversations.set(leadingView: { conversation in
>     MyAvatarView(conversation: conversation)
> })
> ```
>
> The closure is called whenever a row is configured, so build a fresh view from the object
> each time. For full control over layout and reuse, set a cell subclass instead — see
> [Replacing the cell](#replacing-the-cell-uikit).

***

## Example: Custom Leading View

Replace the avatar with the first letter of the conversation's name.

> [tab] SwiftUI
>
> ```swift theme={null}
> CometChatConversations()
>     .cometChatConversationLeadingView { conversation in
>         Text(conversation.title.prefix(1).uppercased())
>             .font(.headline)
>             .foregroundStyle(.white)
>             .frame(width: 48, height: 48)
>             .background(Color(red: 0.41, green: 0.32, blue: 0.84), in: .circle)
>     }
> ```

> [tab] UIKit
>
> ```swift theme={null}
> conversations.set(leadingView: { conversation in
>     let name = (conversation.conversationWith as? User)?.name
>         ?? (conversation.conversationWith as? Group)?.name ?? ""
>     let label = UILabel()
>     label.text = name.first.map { String($0).uppercased() } ?? "?"
>     label.textAlignment = .center
>     label.textColor = .white
>     label.backgroundColor = UIColor(red: 0.41, green: 0.32, blue: 0.84, alpha: 1)
>     label.layer.cornerRadius = 24
>     label.clipsToBounds = true
>     label.widthAnchor.constraint(equalToConstant: 48).isActive = true
>     label.heightAnchor.constraint(equalToConstant: 48).isActive = true
>     return label
> })
> ```

![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)

A custom leading view (SwiftUI)

***

## Example: Custom Subtitle View

Show "typing…" while someone types, else the last message.

> [tab] SwiftUI
>
> ```swift theme={null}
> CometChatConversations()
>     .cometChatConversationSubtitleView { conversation in
>         Text(conversation.typing != nil ? "typing…" : conversation.lastMessage?.text ?? "New conversation")
>             .lineLimit(1)
>             .foregroundStyle(.secondary)
>     }
> ```

> [tab] UIKit
>
> ```swift theme={null}
> conversations.set(subtitleView: { conversation in
>     let label = UILabel()
>     label.numberOfLines = 1
>     label.textColor = CometChatUIKitTheme.shared.textSecondary
>     switch conversation.lastMessage {
>     case let text as TextMessage: label.text = text.text
>     case is MediaMessage: label.text = "Attachment"
>     default: label.text = "New conversation"
>     }
>     return label
> })
> ```

![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)

A custom subtitle view (SwiftUI)

***

## Replace the Whole Row

> [tab] SwiftUI
>
> ```swift theme={null}
> CometChatConversations(
>     itemView: { conversation, isSelected in
>         AnyView(MyRow(conversation: conversation, selected: isSelected))
>     }
> )
> ```

> [tab] UIKit
>
> ```swift theme={null}
> conversations.set(listItemView: { conversation in
>     MyConversationRow(conversation: conversation)
> })
> ```

![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)

itemView (SwiftUI)

### Replacing the cell (UIKit)

Subclass the built-in cell and set its class to keep the stock 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
    }
}
```

```swift theme={null}
conversations.listItemCellClass = MyConversationCell.self
```

![UIKit Conversations list rendering a custom cell 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)

***

## Toolbar Overflow Menu

Add your own control to the component's toolbar. This is separate from the row slots.

> [tab] SwiftUI
>
> ```swift theme={null}
> CometChatConversations(overflowMenu: {
>     AnyView(Button { showSearch() } label: { Image(systemName: "line.3.horizontal.decrease.circle") })
> })
> ```

> [tab] UIKit
>
> ```swift theme={null}
> let filter = UIBarButtonItem(image: UIImage(systemName: "line.3.horizontal.decrease.circle"),
>                              primaryAction: UIAction { _ in showSearch() })
> conversations.setOverflowMenu(filter)
> ```

***

## Components with View Slots

> [tab] SwiftUI
>
> | Component | Closure receives | Modifiers |
> | - | - | - |
> | `CometChatConversations` | `ChatConversation` | `cometChatConversationLeadingView`, `…TitleView`, `…SubtitleView`, `…TrailingView`, `…ItemView` |
> | `CometChatUsers` | `ChatUser` | `cometChatUserLeadingView`, `…TitleView`, `…SubtitleView`, `…TrailingView`, `…ItemView` |
> | `CometChatGroups` | `ChatGroup` | `cometChatGroupLeadingView`, `…TitleView`, `…SubtitleView`, `…TrailingView`, `…ItemView` |
> | `CometChatGroupMembers` | `ChatGroupMember` | `cometChatGroupMemberLeadingView`, `…TitleView`, `…SubtitleView`, `…ListItemView` |
> | `CometChatCallLogs` | `ChatCallLog` | `cometChatCallLogLeadingView`, `…TitleView`, `…SubtitleView`, `…TrailingView`, `…ListItemView` |
> | `CometChatMessageHeader` | `ChatUser?`, `ChatGroup?` | `cometChatMessageHeaderLeadingView`, `…TitleView`, `…SubtitleView`, `…TrailingView`, `…ItemView` |
> | `CometChatReactionList` | the reacted user | `cometChatReactionListLeadingView`, `…TitleView`, `…SubtitleView`, `…TrailingView`, `…ItemView` |
> | `CometChatSavedMessages` | the saved message | `cometChatSavedMessageLeadingView`, `…TitleView`, `…SubtitleView`, `…TrailingView`, `…ItemView` |

> [tab] UIKit
>
> | Component | Closure receives | Setters |
> | - | - | - |
> | `CometChatConversations` | `Conversation` | `leadingView`, `titleView`, `subtitleView`, `trailView`, `listItemView` |
> | `CometChatUsers` | `User?` | `leadingView`, `titleView`, `trailingView`, `listItemView` |
> | `CometChatGroups` | `Group` | `leadingView`, `titleView`, `trailingView`, `listItemView` |
> | `CometChatGroupMembers` | `GroupMember?` | `leadingView`, `titleView`, `subtitleView`, `trailView`, `listItemView` |
> | `CometChatCallLogs` | `ChatCallLog` | `leadingView`, `titleView`, `subtitleView`, `trailView`, `listItemView` |
> | `CometChatMessageHeader` | `User?`, `Group?` | `leadingView`, `titleView`, `subtitleView`, `trailView`, `listItemView` |
> | `CometChatReactionList` | `Reaction` | `leadingView`, `titleView`, `subtitleView`, `listItemView` |

The message composer has slots of its own — header, footer, send button, auxiliary button and
the rich-text toolbar's trailing buttons — documented on the composer page. The message list's
bubbles are drawn by bubble factories (SwiftUI) and templates (UIKit); see
[Message Bubble Styling](https://www.cometchat.com/docs/ui-kit/ios/v6/message-bubble-styling.md).

***

## Related

* [Styles](https://www.cometchat.com/docs/ui-kit/ios/v6/customization-styles.md) — change appearance without replacing views.
* [State Views](https://www.cometchat.com/docs/ui-kit/ios/v6/customization-state-views.md) — the loading, empty and error views.
* [Customization Overview](https://www.cometchat.com/docs/ui-kit/ios/v6/customization-overview.md) — every customization category.


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