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

# Message Bubble Styling

> Style incoming, outgoing and per-kind message bubbles in the CometChat iOS UI Kit v6 — SwiftUI bubble styles and UIKit bubble styles and templates.

> [accordion] AI Integration Quick Reference
>
> ```json theme={null}
> {
>   "swiftUI": {
>     "hub": "CometChatMessageListStyle.incomingBubbleStyle / outgoingBubbleStyle / actionBubbleStyle — each a MessageBubbleStyle",
>     "perKind": ["textBubbleStyle", "imageBubbleStyle", "videoBubbleStyle", "fileBubbleStyle", "audioBubbleStyle", "audiosBubbleStyle", "pollBubbleStyle", "collaborativeBubbleStyle", "meetCallBubbleStyle", "deleteBubbleStyle", "callActionBubbleStyle (on actionBubbleStyle)"],
>     "apply": "CometChatMessageList(style:)"
>   },
>   "uiKit": {
>     "hub": "MessageListStyle.messageBubbleStyle.incoming / .outgoing — each a MessageBubbleStyle",
>     "listLevel": ["actionBubbleStyle (CometChatActionBubbleStyle)", "callActionBubbleStyle (CallActionBubbleStyle)", "dateSeparatorStyle", "unreadSeparatorStyle", "newMessageIndicatorStyle"],
>     "perKind": "CometChatMessageTemplate closures for the kind's regions",
>     "apply": "messageList.style = style, or CometChatMessageList.style for every new list"
>   },
>   "related": ["/ui-kit/ios/v6/theming", "/ui-kit/ios/v6/component-styling", "/ui-kit/ios/v6/message-list"]
> }
> ```

Configure and style the incoming, outgoing and per-kind bubbles of the message list.

***

## Styling Architecture

Bubbles follow a hub-and-spoke pattern:

1. **Hub styles** — one per side, incoming and outgoing, set the container: background,
   corner radius, border, the sender's name, the time and the text.
2. **Per-kind styles** — text, image, file, audio, poll and the rest — refine one kind's
   content inside the hub.

![The message list with incoming bubbles on the left and outgoing bubbles on the right](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-messageListMixed.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=d1afd10cac22a4e9d085b7e6ff226d42)

> [tab] SwiftUI
>
> `CometChatMessageListStyle` has three hubs — `incomingBubbleStyle`, `outgoingBubbleStyle`
> and `actionBubbleStyle` (the centred group-action and call lines) — each a
> `MessageBubbleStyle` carrying a style per kind. Everything is optional: unset falls
> through to the theme.

> [tab] UIKit
>
> `MessageListStyle.messageBubbleStyle` has `incoming` and `outgoing`, each a
> `MessageBubbleStyle`. The centred lines have list-level styles of their
> own. The UIKit toolkit has no per-kind style objects: a kind's look beyond the hub is
> changed with a [template](#per-kind-bubbles-with-templates).

### Global Setup

> [tab] SwiftUI
>
> ```swift theme={null}
> var style = CometChatMessageListStyle()
> style.incomingBubbleStyle = MessageBubbleStyle(backgroundColor: Color(red: 1.0, green: 0.93, blue: 0.88))
> style.outgoingBubbleStyle = MessageBubbleStyle(backgroundColor: Color(red: 0.97, green: 0.41, blue: 0.03))
> CometChatMessageList(style: style, user: user)
> ```

> [tab] UIKit
>
> The static style is the default every list created **afterwards** copies:
>
> ```swift theme={null}
> CometChatMessageList.style.messageBubbleStyle.incoming.backgroundColor =
>     UIColor(red: 1.0, green: 0.93, blue: 0.88, alpha: 1)
> CometChatMessageList.style.messageBubbleStyle.outgoing.backgroundColor =
>     UIColor(red: 0.97, green: 0.41, blue: 0.03, alpha: 1)
> ```

### Hub properties

> [tab] SwiftUI
>
> | `MessageBubbleStyle` | Styles |
> | - | - |
> | `backgroundColor`, `cornerRadius`, `borderColor`, `borderWidth` | the container |
> | `senderNameTextColor`, `senderNameFont` | the sender's name in a group |
> | `timeTextColor`, `timeFont` | the time beside the receipt |
> | `textColor`, `textFont` | the message text |

> [tab] UIKit
>
> | `MessageBubbleStyle` | Styles |
> | - | - |
> | `backgroundColor`, `borderColor`, `borderWidth`, `cornerRadius` | the container; a radius left at `-1` takes the Kit's |
> | `headerTextColor`, `headerTextFont` | the sender's name |
> | `timeTextColor`, `timeTextFont` | the time |
> | `textColor`, `textFont`, `linkColor` | the text and its links |
> | `threadedIndicatorTextColor`, `threadedIndicatorTextFont`, `threadedIndicatorImageTint` | "N replies" |
> | `separatorColor` | the line between a translated message and its translation; left unset it is the theme's `neutral400` on an incoming bubble and white at 20 % on an outgoing one, and a colour you set replaces both |
> | `linkPreviewStrokeColor`, `linkPreviewStrokeWidth` | the link preview's card |
> | `deleteBubbleTextColor`, `deleteBubbleTextFont`, `deleteBubbleIconTint` | the tombstone |

***

## Core Message Bubbles

The SwiftUI examples set a per-kind style on the outgoing hub; set it on `incomingBubbleStyle`
for the other side.

### Text Bubble

> [tab] SwiftUI
>
> ```swift theme={null}
> var text = TextBubbleStyle()
> text.textColor = .white
> text.linkColor = .yellow
> text.mentionColor = .yellow
> text.codeBackground = .black.opacity(0.2)
>
> var outgoing = MessageBubbleStyle(backgroundColor: .indigo, cornerRadius: 16)
> outgoing.textBubbleStyle = text
>
> var style = CometChatMessageListStyle()
> style.outgoingBubbleStyle = outgoing
> CometChatMessageList(style: style, user: user)
> ```
>
> `TextBubbleStyle` also has `textFont`, `codeTextColor`, `quoteBarColor`, and
> `separatorColor`, the line between a translated message and its translation. Its
> `linkPreviewStrokeColor` and `linkPreviewStrokeWidth` change nothing: this toolkit draws no
> link preview.

> [tab] UIKit
>
> Text is styled on the hub:
>
> ```swift theme={null}
> let style = MessageListStyle()
> style.messageBubbleStyle.outgoing.backgroundColor = .systemIndigo
> style.messageBubbleStyle.outgoing.textColor = .white
> style.messageBubbleStyle.outgoing.linkColor = .systemYellow
> style.messageBubbleStyle.incoming.textFont = .preferredFont(forTextStyle: .callout)
> messageList.style = style
> ```

### Image and Video Bubbles

One bubble draws one or many attachments as a grid with "+N".

> [tab] SwiftUI
>
> ```swift theme={null}
> var image = ImageBubbleStyle()
> image.tileCornerRadius = 12
> image.gridSpacing = 4
> image.captionColor = .white
>
> var video = VideoBubbleStyle()
> video.tileCornerRadius = 12
> video.playIconTint = .white
> video.showVideoDuration = true
>
> var outgoing = MessageBubbleStyle()
> outgoing.imageBubbleStyle = image
> outgoing.videoBubbleStyle = video
> var style = CometChatMessageListStyle()
> style.outgoingBubbleStyle = outgoing
> CometChatMessageList(style: style, user: user)
> ```
>
> Both also take `placeholderColor`, `overflowScrimColor`, `overflowTextColor` and
> `overflowTextFont`; video adds `playBadgeBackground` and the duration pill's colours and
> font.

> [tab] UIKit
>
> The container comes from the hub. To change the content, register a template for
> `message` / `image` or `message` / `video` — see
> [Per-kind bubbles with templates](#per-kind-bubbles-with-templates).

### File Bubble

> [tab] SwiftUI
>
> ```swift theme={null}
> var file = FileBubbleStyle()
> file.cardBackground = .white.opacity(0.15)
> file.nameColor = .white
> file.metaColor = .white.opacity(0.7)
> file.downloadTint = .white
>
> var outgoing = MessageBubbleStyle()
> outgoing.fileBubbleStyle = file
> var style = CometChatMessageListStyle()
> style.outgoingBubbleStyle = outgoing
> CometChatMessageList(style: style, user: user)
> ```
>
> `cardCornerLarge` / `cardCornerSmall` shape the cards; `expandColor` / `expandFont` style
> "Show more"; `downloadAll…` the download-all button.

> [tab] UIKit
>
> Register a template for `message` / `file` to replace the content.

### Audio Bubbles

`audioBubbleStyle` styles the voice note and a single audio file; `audiosBubbleStyle` the
multi-file audio card.

> [tab] SwiftUI
>
> ```swift theme={null}
> var voice = AudioBubbleStyle()
> voice.playIconTint = .white
> voice.buttonBackgroundColor = .white.opacity(0.2)
> voice.playedBarColor = .white
> voice.unplayedBarColor = .white.opacity(0.4)
>
> var audios = AudiosBubbleStyle()
> audios.cardBackgroundColor = .white.opacity(0.15)
> audios.seekFillColor = .white
>
> var outgoing = MessageBubbleStyle()
> outgoing.audioBubbleStyle = voice
> outgoing.audiosBubbleStyle = audios
> var style = CometChatMessageListStyle()
> style.outgoingBubbleStyle = outgoing
> CometChatMessageList(style: style, user: user)
> ```

> [tab] UIKit
>
> Register a template for `message` / `audio`; it draws voice notes too.

### Sticker Bubble

A sticker draws without a bubble, so it has no style of its own in either toolkit. Replace it
with your own bubble factory (SwiftUI) or a `custom` / `extension_sticker` template (UIKit).

### Poll Bubble

> [tab] SwiftUI
>
> ```swift theme={null}
> var poll = PollBubbleStyle()
> poll.questionColor = .white
> poll.optionColor = .white
> poll.selectedTint = .yellow
> poll.progressColor = .yellow
> poll.progressTrack = .white.opacity(0.3)
>
> var outgoing = MessageBubbleStyle()
> outgoing.pollBubbleStyle = poll
> var style = CometChatMessageListStyle()
> style.outgoingBubbleStyle = outgoing
> CometChatMessageList(style: style, user: user)
> ```
>
> The voters' avatars take `avatarStyle`; the radio buttons the `…RadioButton…` properties.

> [tab] UIKit
>
> Register a template for `custom` / `extension_poll`.

### Collaborative Bubble

Documents and whiteboards.

> [tab] SwiftUI
>
> ```swift theme={null}
> var collaborative = CollaborativeBubbleStyle()
> collaborative.titleTextColor = .white
> collaborative.buttonTextColor = .yellow
> collaborative.separatorColor = .white.opacity(0.3)
>
> var outgoing = MessageBubbleStyle()
> outgoing.collaborativeBubbleStyle = collaborative
> var style = CometChatMessageListStyle()
> style.outgoingBubbleStyle = outgoing
> CometChatMessageList(style: style, user: user)
> ```

> [tab] UIKit
>
> Register a template for `custom` / `extension_document` or `extension_whiteboard`.

### Meet Call Bubble

> [tab] SwiftUI
>
> ```swift theme={null}
> var meeting = MeetCallBubbleStyle()
> meeting.callIconTint = .white
> meeting.iconBackgroundColor = .white.opacity(0.2)
> meeting.titleTextColor = .white
> meeting.joinButtonTextColor = .yellow
>
> var outgoing = MessageBubbleStyle()
> outgoing.meetCallBubbleStyle = meeting
> var style = CometChatMessageListStyle()
> style.outgoingBubbleStyle = outgoing
> CometChatMessageList(style: style, user: user)
> ```

> [tab] UIKit
>
> Register a template for `custom` / `meeting`.

### Delete Bubble

> [tab] SwiftUI
>
> ```swift theme={null}
> var outgoing = MessageBubbleStyle()
> outgoing.deleteBubbleStyle = DeleteBubbleStyle(textColor: .white.opacity(0.7), iconTint: .white)
> var style = CometChatMessageListStyle()
> style.outgoingBubbleStyle = outgoing
> CometChatMessageList(style: style, user: user)
> ```

> [tab] UIKit
>
> ```swift theme={null}
> let style = MessageListStyle()
> style.messageBubbleStyle.outgoing.deleteBubbleTextColor = .white
> style.messageBubbleStyle.outgoing.deleteBubbleIconTint = .white
> messageList.style = style
> ```
>
> A deleted message always draws the built-in tombstone, whatever a template registers.

***

## List-Level Bubbles

Centred lines that belong to neither side.

### Call Action Bubble

> [tab] SwiftUI
>
> ```swift theme={null}
> var call = CallActionBubbleStyle()
> call.textColor = .secondary
> call.missedCallTextColor = .red
> call.missedCallIconTint = .red
>
> var action = MessageBubbleStyle()
> action.callActionBubbleStyle = call
> var style = CometChatMessageListStyle()
> style.actionBubbleStyle = action
> CometChatMessageList(style: style, user: user)
> ```

> [tab] UIKit
>
> ```swift theme={null}
> let style = MessageListStyle()
> style.callActionBubbleStyle.textColor = .secondaryLabel
> style.callActionBubbleStyle.missedCallTextColor = .systemRed
> style.callActionBubbleStyle.missedCallIconTint = .systemRed
> messageList.style = style
> ```

### Action Bubble

Group actions — "Alice added Kabir".

> [tab] SwiftUI
>
> ```swift theme={null}
> var style = CometChatMessageListStyle()
> style.actionBubbleStyle = MessageBubbleStyle(backgroundColor: .gray.opacity(0.15), cornerRadius: 12,
>                                              textColor: .secondary)
> CometChatMessageList(style: style, group: group)
> ```

> [tab] UIKit
>
> ```swift theme={null}
> let style = MessageListStyle()
> style.actionBubbleStyle.backgroundColor = .tertiarySystemFill
> style.actionBubbleStyle.textColor = .secondaryLabel
> style.actionBubbleStyle.cornerRadius = 12
> messageList.style = style
> ```

### Separators and indicators

> [tab] SwiftUI
>
> `dateSeparatorStyle`, `unreadSeparatorStyle`, `newMessageIndicatorStyle`,
> `threadIndicatorStyle`, `reactionStyle` and the reply quote's
> `incomingMessagePreviewStyle` / `outgoingMessagePreviewStyle` sit on
> `CometChatMessageListStyle`.

> [tab] UIKit
>
> ```swift theme={null}
> let style = MessageListStyle()
> style.dateSeparatorStyle.textColor = .secondaryLabel
> style.unreadSeparatorStyle.lineColor = .systemRed
> style.newMessageIndicatorStyle.badgeBackgroundColor = .systemRed
> messageList.style = style
> ```

***

## Per-kind bubbles with templates

> [tab] SwiftUI
>
> A bubble factory draws one kind. Register yours with `bubbleFactories`; it replaces the
> built-in for that kind. See [Message List](https://www.cometchat.com/docs/ui-kit/ios/v6/message-list.md).

> [tab] UIKit
>
> A `CometChatMessageTemplate` keyed by `category` and `type` replaces a region of one kind
> — `contentView`, `headerView`, `statusInfoView`, `footerView`, or the whole `bubbleView`.
> `nil` keeps the built-in:
>
> ```swift theme={null}
> let roundedImage = CometChatMessageTemplate(category: "message", type: "image", contentView: { message, _, _ in
>     guard let url = (message as? MediaMessage)?.attachment?.fileUrl else { return nil }
>     let view = UIImageView()
>     view.layer.cornerRadius = 16
>     view.clipsToBounds = true
>     view.accessibilityLabel = url
>     return view
> })
> messageList.add(templates: [roundedImage])
> ```
>
> See [Message List](https://www.cometchat.com/docs/ui-kit/ios/v6/message-list.md) for every closure.

## Next Steps

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

> [card] [Theme Introduction](https://www.cometchat.com/docs/ui-kit/ios/v6/theming.md)
>
> Change the colours every bubble reads.


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