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

> The input at the bottom of a chat: text, rich-text formatting, mentions, edit and reply, attachments, voice notes, stickers, polls and AI agents.

`CometChatMessageComposer` is the input at the bottom of a conversation. It sends text,
media, voice notes and stickers to a user, a group or a thread, and it handles editing,
replying, mentions, rich-text formatting, attachments, polls, collaborative documents and
AI agent chats.

![CometChatMessageComposer with a typed draft, attachment, sticker, voice and send buttons](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-overview-message-composer.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=76e55f340caa548eb5806c9a93f2ee04)

***

## Where It Fits

Give it the chat's `User` or `Group`, and a parent message id for a thread. It sends through
the Kit, so the message list and Conversations update without any wiring. It listens to the
Kit's event bus, so an **Edit** or **Reply** chosen in the message list opens here.

```
CometChatMessageHeader
CometChatMessageList
CometChatMessageComposer   ← you are here
   (sticker keyboard, when open)
```

State lives in `MessageComposerStore`, shared by both toolkits.

***

## Quick Start

> [tab] SwiftUI
>
> ```swift theme={null}
> struct ChatScreen: View {
>     let user: CometChatSDK.User
>
>     var body: some View {
>         VStack(spacing: 0) {
>             Spacer()   // your message list
>             CometChatMessageComposer(user: user)
>         }
>     }
> }
> ```
>
> In a chat, host the composer as a bar over the message list, as [Conversation List + Message View](https://www.cometchat.com/docs/ui-kit/ios/v6/conversation-message-view.md#step-2-set-up-the-message-screen) shows.
>
> ![The SwiftUI message composer at rest: attachment button, the Type your message placeholder, sticker and microphone buttons, and a disabled send button](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-composerIdle.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=fa41617a44241e622fa9bbb6b1b72b46)

> [tab] UIKit
>
> Pin it to the keyboard layout guide so it rides above the keyboard, and forward window
> resizes on iPad:
>
> ```swift theme={null}
> final class ChatViewController: UIViewController {
>     var user: CometChatSDK.User!
>     private let composer = CometChatMessageComposer()
>
>     override func viewDidLoad() {
>         super.viewDidLoad()
>         view.backgroundColor = .systemBackground
>         composer.set(user: user)
>
>         composer.translatesAutoresizingMaskIntoConstraints = false
>         view.addSubview(composer)
>         NSLayoutConstraint.activate([
>             composer.leadingAnchor.constraint(equalTo: view.leadingAnchor),
>             composer.trailingAnchor.constraint(equalTo: view.trailingAnchor),
>             composer.bottomAnchor.constraint(equalTo: view.keyboardLayoutGuide.topAnchor),
>         ])
>     }
>
>     override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
>         super.viewWillTransition(to: size, with: coordinator)
>         composer.handleWindowSizeTransition(to: size, with: coordinator)
>     }
> }
> ```
>
> ![The UIKit message composer at rest: attachment button, the Type your message placeholder, sticker and microphone buttons, and a disabled send button](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-uikitComposerIdle.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=4c1ec6a26130ec5d26ff2a050c63e6d4)

In the default single-line layout the composer is a row of shapes floating over your
content, with no bar behind them:

```
[ reply / edit preview card            ]
[ attachment tray                      ]
[ + ][ —— text input —— 🙂 ][ 🎤 ][ ➤ ]
[ —— formatting toolbar (on focus) —— ]
```

* **`+`** opens the attachment menu.
* **The input** grows with the text up to five lines, then scrolls. While it is taller than
  one line, the other shapes stay at its bottom.
* **The sticker button** sits inside the input, at its trailing end, and stays by the last
  line as the input grows. With `hideStickersButton`, the input holds the text only.
* **The mic** is a circle of its own after the input. It stays while you type. With
  `hideVoiceRecordingButton`, no mic circle is drawn.
* **Send** is always there: the Kit's send glyph in white on a `neutral300` circle with
  nothing to send, on `primary` once there is text or an uploaded file, and a stop button
  while an AI agent replies.
* The previews and the tray sit on cards above the row. The formatting toolbar, when it is
  shown, sits below it while the input has focus.
* In a right-to-left layout the row mirrors: `+` on the right, send on the left, and the
  sticker at the input's left end.

On iOS 26 `+`, the input, the mic and the toolbar are Liquid Glass. On iOS 18–25, and with
Reduce Transparency on, the same shapes take the theme's solid fill with a hairline outline.
The send circle is solid on every path, with no outline, and never glass.

> [tab] SwiftUI
>
> The input grows up to `maxLines` lines, five by default. `cometChatRenderPath` picks the
> glass or opaque path, as for every component.
>
> A group works the same way. For a thread, pass the parent message's id too:
>
> ```swift theme={null}
> CometChatMessageComposer(group: group)
> CometChatMessageComposer(group: group, parentMessageId: parentMessage.id)
> ```
>
> The composer sits above the keyboard and moves with it. It starts listening to the event
> bus when it appears, and ends any typing indicator when it disappears.
>
> > [!NOTE]
> >
> > `parentMessageId` is applied only when it is above `-1`. Changing it back to `-1` on the
> > same composer leaves it in the old thread — give the thread its own composer instead, for
> > example with `.id(parentMessageId)`.

> [tab] UIKit
>
> A shown AI button sits before the microphone in the same shape, which is then a pill.
> `renderPath = .fallback` forces the opaque look.
>
> The composer sizes itself: give it no height constraint. For a group, or a reply thread,
> set the group and the parent message's id:
>
> ```swift theme={null}
> composer.set(group: designTeam)
> composer.set(group: designTeam).set(parentMessageId: threadParent.id)
> ```
>
> > [!NOTE]
> >
> > The store starts the first time the composer moves into a window. The attachment sheet,
> > pickers, the poll form and the link dialogs are presented by the view controller that
> > owns the composer. The camera and the recorder need `NSCameraUsageDescription` and
> > `NSMicrophoneUsageDescription` in your `Info.plist`.
>
> > [!WARNING]
> >
> > **Once the composer leaves the window it stops updating.** Detaching it — when another
> > screen is pushed over the chat, or a full-screen modal covers it — stops the store's
> > updates and the mention machinery, and moving back into the window does not restart
> > them: previews, the tray, errors and mention suggestions stop. Create a new composer when
> > the chat screen comes back, or keep the chat on screen.

Prerequisites: the Kit initialised, a user logged in, and the package added. See
[SwiftUI Getting Started](https://www.cometchat.com/docs/ui-kit/ios/v6/getting-started-swiftui.md) or
[UIKit Getting Started](https://www.cometchat.com/docs/ui-kit/ios/v6/getting-started-uikit.md).

***

## Sending

The text goes out as **markdown** where formatting is on, with its mentions as `<@uid:…>`
tokens. Blank text sends nothing. The input clears as soon as the message is handed off. A
failed send reaches `onError`, and the message stays in the list with an error receipt. The
draft is not restored and nothing re-sends it.

> [tab] SwiftUI
>
> * **Staged attachments go first.** When every file in the tray has uploaded, Send sends
>   them — the text becomes the caption — and nothing else.
> * **Replying**, the message goes out quoted, and the reply preview closes when the send
>   succeeds.
> * A failed send reaches `onError` once.
>
> ### Replace the send
>
> `onSendButtonClick` **replaces** the send. The composer builds the text message, with its
> mentions, and hands it to you. The Kit sends nothing:
>
> ```swift theme={null}
> CometChatMessageComposer(
>     user: user,
>     onSendButtonClick: { message in sendThroughMyBackend(message) }
> )
> ```
>
> > [!WARNING]
> >
> > This applies in edit mode too: no edit is made, and **edit mode stays on**. It is not
> > called when staged attachments are sent. The input is still cleared.

> [tab] UIKit
>
> Send is active when the text is not blank, or when every staged attachment has uploaded.
> A tap:
>
> | Situation | What is sent |
> | - | - |
> | attachments staged | one media message per kind — images, then videos, audio, files — with the text as the caption of the last |
> | editing | the edit; edit mode ends |
> | replying | a text message quoting the reply; reply mode ends at once, whatever the result |
> | otherwise | a text message |
>
> The text goes out as markdown only when a rich-text format is configured; otherwise as
> typed. A failed send reaches `onError` **twice**.
>
> ```swift theme={null}
> composer
>     .set(onSendButtonClick: { markdown in track(markdown) })
>     .set(onError: { error in log(error) })
> ```
>
> > [!WARNING]
> >
> > `set(onSendButtonClick:)` is a **notification after the Kit sends**, with the markdown
> > text: the message's `ccMessageSent` in progress has already gone out, and the result
> > arrives later. It is not called for edits. To change or stop a send, subclass and
> > override `didDefaultSendButtonClicked()`.
>
> ```swift theme={null}
> final class ModeratedComposer: CometChatMessageComposer {
>     override func didDefaultSendButtonClicked() {
>         guard passesModeration(text) else { return }
>         super.didDefaultSendButtonClicked()
>     }
> }
> ```

***

## Edit and Reply

The composer enters edit or reply mode when the Kit's event bus says so. The message list
does this for you: its **Edit** and **Reply** actions start them, and the composer whose
chat and thread match picks them up. Edit and reply exclude each other: entering one closes
the other.

> [tab] SwiftUI
>
> From your own UI, call the store:
>
> ```swift theme={null}
> struct ChatComposer: View {
>     let user: CometChatSDK.User
>     @State private var store = MessageComposerStore()
>
>     var body: some View {
>         CometChatMessageComposer(user: user, store: store)
>     }
>
>     func reply(to message: BaseMessage) { store.setReplyMessage(message) }
>     func edit(_ message: BaseMessage) { store.setEditMessage(message) }
> }
> ```
>
> Or emit the event, as the message list does:
>
> ```swift theme={null}
> CometChatEvents.emitMessageEvent(.replyToMessage(message: parentMessage, status: .inProgress))
> ```
>
> **Edit** fills the input with the message's text, or with a media message's caption,
> and shows the edit preview. Send then saves the edit. Mentions come back as mentions, and
> fenced code comes back as a code block. Edit mode ends when you tap Send, not when the
> edit completes. The edited message carries the new text only: no metadata, and no
> `mentionedUsers`.
>
> **Reply** shows the reply preview — the sender's name, or "You", over a line of the
> message or the kind of media. A deleted text message reads "This message was deleted";
> a deleted media message still shows its old content. The next text, media, voice note or
> sticker goes out quoting it.
>
> ![The composer in reply mode: a reply preview quoting Nancy Grace's Lunch at noon? above a typed answer, with a close button](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-composerReply.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=7efd080c3d0067d9eb852575cfa6a554)
>
> | Close | Effect |
> | - | - |
> | the edit preview's ✕ | leaves edit mode **and clears the input** |
> | the reply preview's ✕ | leaves reply mode, keeps the input |
>
> > [!NOTE]
> >
> > Loading an edit runs the text through the editor's typing path. The **first** inline
> > markdown shortcut in the text becomes formatting, and the rest stay as literal markers:
> > `**a** and _b_` loads as bold **a** and a literal `_b_`. What you save serialises back to
> > the same markdown.
>
> `hideMessagePreview: true` hides the reply preview only. The reply is still active: the
> next message goes out quoted, and nothing on screen says so. There is no flag for the edit
> preview; replace it with a [custom view](#custom-view-slots) instead.

> [tab] UIKit
>
> You can start them directly:
>
> ```swift theme={null}
> composer.edit(message: sentMessage)
> composer.exitEditMode()
>
> composer.reply(message: sentMessage)
> composer.exitReplyMode()
> ```
>
> | Method | Does |
> | - | - |
> | `edit(message:)` | fills the input with a `TextMessage`'s text — markdown back into formats when rich text is configured — and shows the edit preview |
> | `set(editMessage:)` | the same through the store only; consumed mentions are not restored |
> | `exitEditMode()` | leaves edit mode and clears the input |
> | `reply(message:)` | shows the reply preview; the next send quotes it |
> | `exitReplyMode()` | leaves reply mode |
>
> `edit(message:)` takes a `TextMessage`. The reply preview is titled "You" for your own
> message, runs the text formatters but shows markdown markers as typed, and says "This
> message was deleted" only for a deleted text message.
>
> ```swift theme={null}
> composer.set(hideEditPreview: true).set(hideMessagePreview: true)
> ```
>
> `set(hideMessagePreview:)` hides the reply preview, **not the reply**: the next message
> still goes out quoted. There is no edit- or reply-preview slot — subclass
> `presentEditPreview(for:)` instead.

***

## Rich Text

> [tab] SwiftUI
>
> Formatting is **off by default**. The toolbar under the input shows only when
> `enableRichTextFormatting` is `true` **and** `enabledFormats` is not empty, and only
> **while the input has focus**. It slides up with the keyboard, at the keyboard's speed, and
> back down when focus leaves. Recording and the sticker keyboard take focus, so it hides
> then too. In agent chat it never shows. Without it, focus raises only the keyboard:
>
> ```swift theme={null}
> CometChatMessageComposer(
>     user: user,
>     enableRichTextFormatting: true,
>     enabledFormats: [.bold, .italic, .underline, .strikethrough, .link, .inlineCode, .codeBlock]
> )
> ```
>
> ![The composer with the formatting toolbar under the input and a draft reading Ship the release notes by Friday, with release notes in bold and Friday in italic](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-composerRichText.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=fc0b88ba99ec8bd1a649f6090acd47cf)
>
> | Format | Sent as |
> | - | - |
> | `.bold` | `**text**` |
> | `.italic` | `_text_` |
> | `.underline` | `<u>text</u>` |
> | `.strikethrough` | `~~text~~` |
> | `.inlineCode` | `` `text` `` |
> | `.codeBlock` | a fenced block |
> | `.link` | `[text](url)` |
> | `.bulletList`, `.orderedList` | `- ` and `1. ` lines |
> | `.blockquote` | `> ` lines |
>
> The message list renders the markdown back.
>
> Once `enabledFormats` is not empty, three more things work, **whatever
> `enableRichTextFormatting` says**:
>
> * **The selection menu** adds Bold, Italic, Strikethrough and Code to Cut, Copy and Paste,
>   even for formats you did not enable. These four titles are English in every language.
> * **Links.** With the caret in a link, the system alert shows the URL — tap it to open the
>   link — and offers Edit, Remove and Cancel. With a selection, Link opens the Add Link dialog
>   (drawn as the system alert) with the text filled in; Save stays off while the link is blank.
> * **Code blocks.** Typing ` ``` ` starts a code block. Enter twice leaves it, and Backspace
>   removes it when it is empty. An empty code block turns Send on, but tapping Send then
>   sends nothing.
>
> So to keep the selection menu without the toolbar, leave `enableRichTextFormatting`
> `false` and set `enabledFormats`. The mention styling in the input also needs
> `enabledFormats`: without it, a mention in the draft is plain text until it is sent.
>
> ### Your own toolbar button
>
> `trailingToolbarContent` adds a view at the end of the toolbar. It receives a
> `ComposerInputController` for the live input — read the text and selection, insert text,
> toggle a format:
>
> ```swift theme={null}
> CometChatMessageComposer(
>     user: user,
>     enableRichTextFormatting: true,
>     enabledFormats: Set(RichTextFormat.allCases),
>     trailingToolbarContent: { input in
>         AnyView(Button("Sign") { input.insertAtCursor(" — Alice") })
>     }
> )
> ```
>
> It shows only while the toolbar does. Do not keep the controller after the view goes.

> [tab] UIKit
>
> Two switches, both needed:
>
> | Switch | Default | Gates |
> | - | - | - |
> | `enableRichTextFormatting` | `true` | the selection menu and `set(showFormattingToolbar:)` |
> | `set(richTextConfiguration:)` | all off | markdown on send, shortcuts, list continuation, pasted links, the edit prefill, and every format action |
>
> So by default the selection menu shows Bold, Italic, Strikethrough and Inline code, and
> they do nothing. Configure formats and show the toolbar:
>
> ```swift theme={null}
> composer
>     .set(richTextConfiguration: RichTextConfiguration(enableBold: true, enableItalic: true, enableLink: true))
>     .show(richTextFormattingOptions: true)
> ```
>
> ![The UIKit composer with the formatting toolbar under the input and a draft reading Ship the release notes by Friday, with release notes in bold and Friday in italic](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-uikitComposerRichText.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=109e6116ac8e2f6b89c426908ed924b1)
>
> `show(richTextFormattingOptions:)` (or `showRichTextFormattingOptions = true`) turns on the
> toolbar under the input. It shows **while the input has focus**: it slides up with the
> keyboard, on the keyboard's own animation, and back down when focus leaves. Recording and
> the sticker keyboard take focus, so it hides then too. In agent chat it never shows. With
> no format configured it configures all ten; it also turns the selection menu's items back on. `RichTextConfiguration` has presets:
> `.allEnabled()`, `.basicFormatting()`, `.codeFormatting()`, `.listFormatting()`.
>
> > [!NOTE]
> >
> > The configuration is an on/off switch: once **any** format is configured, the toolbar
> > shows all ten buttons and every shortcut below works. Configuring a format also turns
> > keyboard suggestions, autocorrection and sentence capitalisation off, for good.
>
> ### Markdown shortcuts
>
> Typed while a format is configured:
>
> | Type | Becomes |
> | - | - |
> | `**text**` | bold |
> | `_text_` | italic |
> | `~~text~~` | strikethrough |
> | `<u>text</u>` | underline |
> | `` `text` `` | inline code |
> | ` ``` ` at a line start | a code block |
> | `- ` / `1. ` / `> ` at a line start | a bullet list, an ordered list, a quote |
> | `[text](https://…)` | a link |
>
> **Enter** continues a list or a quote on the next line, numbering ordered items; Enter on
> an empty item ends it. **Pasted** `[text](url)` becomes a link.
>
> ### Links
>
> The toolbar's link button opens the **Add Link** dialog, drawn as the system alert — text
> and URL; Save with a blank URL changes nothing — or, over a selected link, the link popup. Tapping a link in the input opens the
> popup: the system alert with the URL, which opens in the browser when tapped, **Edit**,
> **Remove** and **Cancel**.
>
> ### Selection menu
>
> Selecting text adds **Bold**, **Italic**, **Strikethrough** and **Inline code** to the
> edit menu. Turn them off with `set(showTextSelectionMenuItems: false)`, or turn the menu
> off with `enableRichTextFormatting = false`.
>
> ### A button after the toolbar
>
> `set(richTextToolbarTrailingView:)` adds a view after the single-line toolbar's buttons.
> Its `ComposerInputController` edits the live input:
>
> ```swift theme={null}
> composer.set(richTextToolbarTrailingView: { _, _, input in
>     UIButton(type: .system, primaryAction: UIAction(image: UIImage(systemName: "signature")) { _ in
>         input.insertAtCursor("\n— Alice")
>     })
> })
> ```
>
> The wire format is markdown — `**`, `_`, `<u>…</u>`, `~~`, `` ` ``, fenced blocks, `- `,
> `1. `, `> `, `[text](url)` — which the message list renders.

***

## Layout Mode

The composer has two layouts: the single-line row of shapes described in
[Quick Start](#quick-start), and a multi-line layout with the input on its own, full width,
above a row of buttons. In multi-line, **Aa** swaps the button row for the formatting
toolbar and a close button.

> [tab] SwiftUI
>
> | `layoutMode` | Layout |
> | - | - |
> | `.singleLine` *(default)* | the iOS-standard row of shapes: `+`, the text with the sticker button inside it, the mic, send — the toolbar below while the input has focus |
> | `.multiLine` | the text on its own, full width; below a divider, a row of attachment, mic, sticker, **Aa** and send |
>
> ```swift theme={null}
> CometChatMessageComposer(
>     user: user,
>     enableRichTextFormatting: true,
>     layoutMode: .multiLine,
>     enabledFormats: Set(RichTextFormat.allCases)
> )
> ```
>
> ![The composer in multi-line layout: a three-line draft on its own at full width, and below a divider a row of attachment, microphone, sticker, Aa and send](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-composerMultiLine.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=07ef57eead64188cc47594e86c3af239)
>
> In multi-line mode, **Aa** swaps the button row for the formatting toolbar — ✕ and all ten
> formats — and ✕ swaps it back. The single-line toolbar under the input never shows in
> this mode.
>
> In multi-line mode the input grows to about 200 pt, then scrolls, and `maxLines` has no
> effect. In single-line mode it grows to `maxLines` lines.
>
> > [!NOTE]
> >
> > Two quirks come with multi-line mode:
> >
> > * the second row's attachment button and **Aa** ignore `hideAttachmentButton` and agent
> >   chat;
> > * **Aa** opens the toolbar even with formatting off. Then its format buttons do nothing,
> >   but Link still opens the link dialog.
> >
> > A custom `sendButtonView` is drawn in the second row. `secondaryButtonView` and
> > `auxiliaryButtonView` are not drawn in multi-line mode.

> [tab] UIKit
>
> | Mode | Layout |
> | - | - |
> | `.singleLine` (default) | the iOS-standard row of shapes: `[+] [text … sticker] [mic] [send]`, the toolbar beneath while the input has focus |
> | `.multiLine` | the full-width input, then `[attachment] [mic] [stickers] [Aa] … [send]` |
>
> ```swift theme={null}
> composer.set(layoutMode: .multiLine)
> composer.set(showFormattingToolbar: true)
> ```
>
> `set(showFormattingToolbar:)` swaps the button row for the toolbar in code, and does
> nothing unless the layout is multi-line and `enableRichTextFormatting` is on.
>
> > [!WARNING]
> >
> > Choose the layout once, before the composer is shown. Switching from multi-line back to
> > single-line leaves the send button hidden. In multi-line the row's attachment button and
> > **Aa** ignore the hide flags and agent chat, and **Aa** opens all ten formats with no
> > check — with no format configured, only Link does anything. Custom send, auxiliary and
> > secondary views stay in the input row.

***

## Mentions

Typing `@` opens a list of people to mention: users in a one-to-one chat, members in a
group. The list searches 300 ms after you stop typing, 10 at a time, and loads more as you
scroll. In a group **@all** mentions everyone. On send, each mention goes out as
`<@uid:…>`. At 10 mentions, suggestions stop.

> [tab] SwiftUI
>
> The list shows only when there are results — no loading row, no empty state. Picking
> someone inserts `@Name`. Backspace deletes a whole mention. On send, the user is added to
> the message's `mentionedUsers`.
>
> ![The mention list open above the composer in a group after typing @: @all with Notify everyone in this group, then group members with initials avatars](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-composerMentions.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=8dca19cdd5ee3bf4db362adb10d93dd4)
>
> `textFormatters: nil` — the default — means one `CometChatMentionsFormatter`. Pass your
> own to configure it. Keep it in `@State` so it is not rebuilt on every render:
>
> ```swift theme={null}
> struct TeamComposer: View {
>     let group: CometChatSDK.Group
>     @State private var mentions: CometChatMentionsFormatter = {
>         let formatter = CometChatMentionsFormatter()
>         formatter.mentionLimit = 5
>         formatter.disableMentionAll = true
>         return formatter
>     }()
>
>     var body: some View {
>         CometChatMessageComposer(group: group, textFormatters: [mentions])
>     }
> }
> ```
>
> | Formatter property | Default | Effect |
> | - | - | - |
> | `mentionLimit` | `10` | mentions per message |
> | `disableMentionAll` | `false` | hides @all |
> | `mentionsType` | `.usersAndGroupMembers` | `.users` searches users even in a group |
> | `mentionsVisibility` | `.both` | `.usersConversationOnly` or `.groupConversationOnly` |
> | `setMentionAllLabel(_:_:)` | `all` | @all's id and label, together |
> | `setUsersRequestBuilder(_:)`, `setGroupMembersRequestBuilder(_:)` | the Kit's | filter who can be mentioned |
>
> `onMentionClick` is called after a suggestion is inserted:
>
> ```swift theme={null}
> CometChatMessageComposer(group: group, onMentionClick: { item in log("mentioned \(item.name)") })
> ```
>
> `disableMentions: true` removes **every** text formatter, including your own ones. To keep
> a custom formatter without mentions, pass a `textFormatters` list that has no mentions
> formatter.

> [tab] UIKit
>
> Mentions are not detected inside code. After 10 mentions, an info row says so. Mention-all
> is sent as `<@all:all>`.
>
> ![The UIKit suggestion list open above the composer in a group after typing @: @all first, then group members](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-uikitComposerMentions.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=bb25c5a14c901e4256e2d7c7515c6715)
>
> The mentions formatter is the first text formatter. Configure it through
> `textFormatters`:
>
> ```swift theme={null}
> if let mentions = composer.textFormatters.first as? CometChatMentionsFormatter {
>     mentions.mentionLimit = 5
>     mentions.mentionsVisibility = .groupConversationOnly
>     mentions.disableMentionAll = true
>     mentions.setMentionAllLabel("channel", "channel")
> }
> ```
>
> `set(textFormatter:)` **appends** formatters after it:
>
> ```swift theme={null}
> composer.set(textFormatter: [hashtagFormatter])
> ```
>
> The mentions formatter behaves like this:
>
> * mention-all shows as `@all`, `@` and its id, not `@` and its label;
> * a mention always starts with `@`, and a custom tracking character is ignored;
> * the formatter's `onMentionClick` and `onMentionAllClick` are stored but never called.
>
> The suggestion list:
>
> ```swift theme={null}
> composer
>     .set(suggestionListMaxHeight: 160)
>     .show(suggestionListAvatar: false)
> ```
>
> Style it with `suggestionsStyle`, and mentions in the input with `mentionStyle` — see
> [Style](#style). Ending a mention query does not clear the formatter's rows, so the next
> `@` briefly shows the previous results.

***

## Attachments

The attachment button opens the attachment menu, a sheet of options.

> [tab] SwiftUI
>
> | Option | Default | Does |
> | - | - | - |
> | Camera | shown | takes a photo |
> | Image, Video | shown | the photo library |
> | Audio, Document | shown | the Files picker |
> | Poll | **hidden** | opens [Create Poll](https://www.cometchat.com/docs/ui-kit/ios/v6/create-poll.md) |
> | Collaborative Document | **hidden** | creates a shared document and posts it |
> | Collaborative Whiteboard | **hidden** | creates a shared whiteboard and posts it |
>
> Each has a `hide…Option` flag: `hideCameraOption`, `hideImageOption`, `hideVideoOption`,
> `hideAudioOption`, `hideFileOption`, `hidePollOption`, `hideCollaborativeDocumentOption`,
> `hideCollaborativeWhiteboardOption`. Poll, document and whiteboard are hidden until you
> show them, and they are **never shown inside a thread**:
>
> ```swift theme={null}
> CometChatMessageComposer(
>     group: group,
>     hideVideoOption: true,
>     hideAudioOption: true,
>     hidePollOption: false,
>     hideCollaborativeDocumentOption: false,
>     hideCollaborativeWhiteboardOption: false
> )
> ```
>
> **Replace an option's action** with its callback. Return `true` to skip the Kit's default,
> or `false` to run it after yours: `onCameraClick`, `onImageClick`, `onVideoClick`,
> `onAudioClick`, `onDocumentClick`, `onPollClick`, `onCollaborativeDocumentClick`,
> `onCollaborativeWhiteboardClick`.
>
> ```swift theme={null}
> CometChatMessageComposer(
>     user: user,
>     onCameraClick: {
>         openMyCamera()
>         return true   // skip the Kit's camera
>     }
> )
> ```
>
> `onAttachmentClick` returning `true` stops the menu from opening at all.
>
> > [!NOTE]
> >
> > The camera needs `NSCameraUsageDescription`, and the voice recorder needs
> > `NSMicrophoneUsageDescription`, in your app's Info.plist. The photo library and the
> > Files picker need no permission. A device with no camera reports
> > `MEDIA_SELECTION_ERROR` to `onError`.

> [tab] UIKit
>
> | Option | Default | Visibility | Callback |
> | - | - | - | - |
> | Camera | shown | `set(cameraOptionVisibility:)` | `set(onCameraClick:)` |
> | Photo | shown | `hideImageAttachmentOption` | `set(onImageClick:)` |
> | Video | shown | `hideVideoAttachmentOption` | `set(onVideoClick:)` |
> | Audio | shown | `set(audioOptionVisibility:)` | `set(onAudioClick:)` |
> | Document | shown | `hideFileAttachmentOption` | `set(onDocumentClick:)` |
> | Poll | **hidden** | `hidePollsOption` | `set(onPollClick:)` |
> | Collaborative document | **hidden** | `hideCollaborativeDocumentOption` | `set(onCollaborativeDocumentClick:)` |
> | Collaborative whiteboard | **hidden** | `hideCollaborativeWhiteboardOption` | `set(onCollaborativeWhiteboardClick:)` |
>
> Poll and the two collaborative options are also dropped inside a thread. Each callback
> returns `true` to skip the Kit's default:
>
> ```swift theme={null}
> composer.hidePollsOption = false
> composer.set(onDocumentClick: {
>     presentMyFilePicker()
>     return true
> })
> ```
>
> Send the file yourself with `sendMediaMessage(url:contentType:)`, where the content type
> is `"image"`, `"video"`, `"audio"`, `"file"` or a MIME type:
>
> ```swift theme={null}
> composer.sendMediaMessage(url: pickedFileURL, contentType: "file")
> ```
>
> A callback, or the default, runs once the sheet has gone. `set(onAttachmentClick:)` is
> never called; override `attachmentButtonClicked()` to act on the button.

### Custom Options

> [tab] SwiftUI
>
> `attachmentOptions` are **appended** after the built-in ones. They cannot remove or
> reorder those. A tap goes to `onAttachmentOptionClick`:
>
> ```swift theme={null}
> CometChatMessageComposer(
>     user: user,
>     attachmentOptions: [
>         ComposerAttachmentOption(id: "location", title: "Location", icon: "location.fill")
>     ],
>     onAttachmentOptionClick: { option in
>         if option.id == "location" { shareLocation() }
>     }
> )
> ```
>
> `icon` is an SF Symbol name, or the name of an image in your app's asset catalogue. Only
> `id`, `title` and `icon` are used. The option's own `onClick`, colours, font and corner
> radius are ignored.

> [tab] UIKit
>
> Custom options are **appended** after the built-ins. Only the id, title and icon are used
> (an SF Symbol or an asset name); a tap goes to `set(onAttachmentOptionClick:)`, never to
> the option's own `onClick`.
>
> ```swift theme={null}
> composer
>     .add(attachmentOption: ComposerAttachmentOption(id: "location", title: "Location", icon: "mappin.and.ellipse"))
>     .set(onAttachmentOptionClick: { option in
>         if option.id == "location" { shareLocation() }
>     })
> ```
>
> The options live in the store, so replacing `messageComposerStore` drops them, with the
> visibility flags.

### The Tray

With `enableMultipleAttachments` on — the default — picked files are **staged** in a tray
on a card above the input, and each starts uploading at once. Pasted, keyboard-inserted
and dropped media stage too. Send is possible when every file has uploaded. Each tile has a
✕ to cancel or remove it.

> [tab] SwiftUI
>
> ![The attachment tray on a card above the input with an uploaded image, an image uploading with a progress ring, and a failed image with a retry badge](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-composerTray.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=f3aba90f1471300d8492d99894c93b69)
>
> | Tile | Tap |
> | - | - |
> | uploading — a ring fills to the percent | — |
> | uploaded image | opens the image viewer |
> | uploaded video | opens the system player |
> | uploaded audio | nothing — its play button plays it in the tile |
> | uploaded document | nothing |
> | failed | retries the upload |
> | rejected by the server | shows the reason above the composer |
>
> One Send posts **one message per kind** — images, then videos, then audio, then files.
> The text is the caption of the last message, and a reply quotes the first. The tray clears
> when you tap Send. Messages go one at a time and stop at the first failure.
>
> Staged files are cleared when the user, group or thread changes. In the multi-line layout the mic hides while the tray has files.
>
> **The cap** is your app's file-count setting on the server — from 1 to 1,000 — or 10 when
> it is not set. A full tray will not open a picker. A pick that goes over the cap is
> trimmed. Either way a toast says "You can attach up to N files", and `onError` receives
> `MAX_ATTACHMENTS_EXCEEDED`. The store's `maxAttachmentCount` is read-only.
>
> **`enableMultipleAttachments: false`** sends each pick at once, with no tray, and turns off
> paste and drop:
>
> ```swift theme={null}
> CometChatMessageComposer(user: user, enableMultipleAttachments: false)
> ```

> [tab] UIKit
>
> ![The UIKit attachment tray on a card above the input with an uploaded image, an image uploading with a spinner, and a failed image with a retry badge](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-uikitComposerTray.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=b9ec033a9a8db8192f8970d31b3b151a)
>
> | Tile | Shows | Tap |
> | - | - | - |
> | uploading | a spinner | — |
> | failed | a retry arrow | retries |
> | rejected | an exclamation mark | shows the reason in a banner |
> | uploaded | the thumbnail or card | opens an image or video; plays audio in place |
>
> Send stays inactive until every tile has uploaded. In the multi-line layout the microphone hides while anything is staged.
>
> **The cap** is `messageComposerStore.maxAttachmentCount` — your app's file-count setting
> when it is 1…1000, else 10. A full tray refuses the picker with a toast; extra picks are
> trimmed with one.
>
> Turning `enableMultipleAttachments` off clears the tray, sends each pick at once, and
> ignores paste and drop.

### Polls

> [tab] SwiftUI
>
> `hidePollOption: false` adds **Poll**. It opens
> [`CometChatCreatePoll`](https://www.cometchat.com/docs/ui-kit/ios/v6/create-poll) in a sheet, and the composer
> posts the poll with the Polls extension. While it posts, the form shows "Creating Poll…"
> and the sheet cannot be dismissed. On success the sheet closes. A failure shows in the
> form and does **not** reach `onError`.
>
> To show your own form, return `true` from `onPollClick`:
>
> ```swift theme={null}
> CometChatMessageComposer(
>     group: group,
>     hidePollOption: false,
>     onPollClick: {
>         showMyPollForm()
>         return true
>     }
> )
> ```
>
> Poll needs the Polls extension, enabled on your CometChat dashboard.

> [tab] UIKit
>
> With `hidePollsOption = false`, the Poll option opens [Create Poll](https://www.cometchat.com/docs/ui-kit/ios/v6/create-poll.md)
> in a sheet. The composer creates the poll: success closes the sheet; a failure shows in
> the form and reaches `onError`. The sheet cannot be dismissed while the poll is being
> created.

### Collaborative Document and Whiteboard

> [tab] SwiftUI
>
> Document and whiteboard need the Collaborative Document and Collaborative Whiteboard
> extensions enabled on your CometChat dashboard. A failure shows a toast and reaches
> `onError`.

> [tab] UIKit
>
> Each calls its extension. A failure shows a toast with the reason and reaches `onError`.
> The new message arrives in the list through real-time events.

***

## Voice Notes

Tapping the mic replaces the input row with the inline recorder, which starts recording at
once, asking for the microphone first. The recorder offers delete, pause, play back, resume
and send. Resume works after playing the recording back too: the new audio is added to the
end of the same voice note, as many times as you like, and Send posts one file with every
part, in order. Send posts a voice note, quoted if you are replying.

In the single-line layout the recorder floats like the row it replaces, as three shapes 8 pt
apart: a bin circle, a capsule holding the recording indicator or play button, the waveform,
the time and pause or resume, and the row's own send circle. The bin and the capsule are
Liquid Glass on iOS 26, and the theme's `background1` in a hairline on iOS 18–25 or with
Reduce Transparency; the send is the same solid circle as when you type. There is no panel
behind them. The multi-line layout keeps the recorder as one panel.

The controls inside keep the Kit's look in both layouts: the bin, pause-recording and resume
glyphs in `iconTintSecondary`; play, pause-playback and the recorded waveform in `primary`; the
recording dot in `error`; the time in `textSecondary`.

> [tab] SwiftUI
>
> The mic is always shown in the single-line layout; in the multi-line layout it shows when the
> input is empty and the tray has no files. The recorder moves through three states:
>
> * **Recording** — the time, a live waveform, pause and delete.
> * **Paused** — resume, delete, send.
> * **Done** — play back, seek on the waveform, resume, delete, send.
>
> Send stops the recording first if needed. The edit and reply previews stay above the
> recorder, and the tray below it.
>
> | Shape | Styled by (`CometChatMessageComposerStyle`) |
> | - | - |
> | bin circle, recorder capsule | `backgroundColor` (replaces the glass), `strokeColor`, `strokeWidth`, `cornerRadius` — as every shape |
> | send circle | `sendButtonActiveBackgroundColor`, `sendButtonActiveIcon`, `sendButtonIconTint` — as the send when you type |
>
> ![The voice recorder in place of the input row: a bin circle, a capsule with the recording indicator, a live waveform, the elapsed time and pause, and the send circle](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-composerRecording.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=a3d6a076ee10b0f47ebdd67d53e27d4f)
>
> If the microphone permission is refused, or the recording is empty, `onError` receives
> `RECORDING_ERROR` and the recorder closes. `onVoiceRecordingClick` returning `true` keeps
> the recorder closed, so you can record your own way:
>
> ```swift theme={null}
> CometChatMessageComposer(
>     user: user,
>     onVoiceRecordingClick: {
>         log("recording started")
>         return false   // keep the Kit's recorder
>     }
> )
> ```
>
> > [!NOTE]
> >
> > An error from the recording engine reaches `onError` **twice**.

> [tab] UIKit
>
> The recorder replaces the **whole** compose box — previews and tray included. Then
> `set(onVoiceRecordingClick:)` is called:
>
> ```swift theme={null}
> composer.set(onVoiceRecordingClick: { track("recording") })
> ```
>
> In the single-line layout the shapes are bottom-aligned, 12 pt from the sides, and the three
> come and go together. The multi-line panel is `background1` in a `strokeLight` border, 56 pt
> high, its send a `primary` disc.
>
> | Shape | Styled by (`MessageComposerStyle`) |
> | - | - |
> | bin circle, recorder capsule | `backgroundColor` (replaces the glass), `borderColor`, `borderWidth`, `cornerRadius` — as every shape. The `composeBox…` values stay on the input capsule |
> | send circle | `activeSendButtonBackgroundColor`, `sendButtonImage`, `sendButtonImageTint`, `borderColor` / `borderWidth`, and `cornerRadius` — as the send with something to send |
>
> The bin is 20 pt in its circle.
>
> A refused microphone reports `RECORDING_ERROR` to `onError` and closes the recorder. An
> empty recording slides the recorder away and sends nothing, but leaves the compose box
> hidden. The single-line layout always shows the microphone; the multi-line layout hides it
> while the tray holds files.

***

## Stickers

The sticker button opens the sticker keyboard (see [Sticker Keyboard](https://www.cometchat.com/docs/ui-kit/ios/v6/sticker-keyboard.md))
below the composer, in place of the system keyboard. Tapping a sticker sends it, then calls
the sticker-selected callback; the keyboard stays open. Stickers need the **Stickers**
extension enabled on your dashboard.

> [tab] SwiftUI
>
> The keyboard is as tall as the system keyboard was — at least 296 pt. If the extension is
> not enabled it shows its error state and `onError` receives `ERR_EXTENSION_NOT_ENABLED`.
>
> * Tapping a sticker sends it — quoted if you are replying, when the reply is in this chat
>   and thread — then calls `onStickerSelected`. That is when the send **starts**, not when
>   it completes.
> * The sticker button or a tap in the text field closes it.
> * `onStickerClick` returning `true` stops the button from opening the keyboard.
>
> ```swift theme={null}
> var stickers = CometChatStickerKeyboardStyle()
> stickers.separatorColor = .orange
>
> CometChatMessageComposer(
>     user: user,
>     stickerKeyboardStyle: stickers,
>     onStickerSelected: { sticker in log("sent \(sticker.name)") }
> )
> ```
>
> > [!NOTE]
> >
> > Hiding the sticker button, or starting a recording, while the keyboard is open leaves the
> > keyboard open with no button to close it. A tap in the text field still closes it.

> [tab] UIKit
>
> The keyboard is 296 pt tall, in `bottomPanelLayout`, and hides the system keyboard.
> Tapping the text closes it.
>
> ```swift theme={null}
> composer
>     .set(onStickerClick: { track("stickers toggled") })
>     .set(onStickerSelected: { sticker in track(sticker.name) })
>
> let style = StickerKeyboardStyle()
> style.separatorColor = .systemIndigo
> composer.set(stickerKeyboardStyle: style)
> ```
>
> `set(onStickerClick:)` runs **after** the keyboard toggled. Open or close it in code with
> `showStickerKeyboard()`, `hideStickerKeyboard()` and `toggleStickerKeyboard()`;
> `isStickerKeyboardVisible` reads it.

***

## AI Agents

When the user is an AI agent — a user whose role is `@agentic` — the composer:

* hides the attachment, microphone and sticker buttons and the formatting toolbar. The
  selection menu stays;
* shows an arrow on the send button;
* turns on the **generating** state when you send. The send button shows a stop icon and
  cannot be tapped until the agent's reply has finished streaming, or the send fails.
  There is no way to interrupt the reply;
* starts a thread with the first message you send, and the rest of the conversation goes
  into it.

![The composer in an AI agent chat while the agent is generating: no attachment, sticker or voice buttons, and a stop icon on the send button](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-composerAgent.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=bc507484e2fac52b12107c8a4d95c40e)

> [tab] SwiftUI
>
> The role is matched ignoring case. The hides apply whatever the flags say; the selection
> menu, links and code blocks still work if `enabledFormats` is not empty.
>
> The AI button is always hidden, and `onAIClick` never fires. `aiIcon` and `aiIconTint` are
> never drawn.

> [tab] UIKit
>
> Setting the buttons visible again is ignored.
>
> > [!WARNING]
> >
> > Agent chat is **never undone**: a later `set(user:)` with a person, or `set(group:)`,
> > keeps the buttons hidden. Use a new composer for each chat.
>
> The AI button is separate from agent chat. It is hidden by default; shown, its tap only
> calls `set(onAIClick:)`:
>
> ```swift theme={null}
> composer.hideAIButton = false
> composer.set(onAIClick: { openAssistant() })
> ```

***

## Actions and Events

### Callback Methods

> [tab] SwiftUI
>
> | Callback | Signature | Called |
> | - | - | - |
> | `onSendButtonClick` | `(BaseMessage) -> Void` | instead of sending ([Sending](#sending)) |
> | `onError` | `(CometChatError) -> Void` | once per error |
> | `onTextChanged` | `(String) -> Void` | on typing, on caret and selection moves, and when a mention is inserted or deleted. It receives the **edited block's** text — the whole text, unless there is a code block. Not called when the input is cleared after a send or filled by `ComposeMessage` |
> | `onAttachmentClick` | `() -> Bool` | the attachment button; `true` keeps the menu closed |
> | `onCameraClick` … `onCollaborativeWhiteboardClick` | `() -> Bool` | a built-in option; `true` skips its default |
> | `onAttachmentOptionClick` | `(ComposerAttachmentOption) -> Void` | a custom option |
> | `onVoiceRecordingClick` | `() -> Bool` | the mic; `true` keeps the recorder closed |
> | `onStickerClick` | `() -> Bool` | the sticker button; `true` keeps the keyboard closed |
> | `onStickerSelected` | `(Sticker) -> Void` | after a sticker's send starts |
> | `onMentionClick` | `(SuggestionItem) -> Void` | after a mention is inserted |
> | `onAIClick` | `() -> Bool` | never |
>
> ```swift theme={null}
> CometChatMessageComposer(
>     user: user,
>     onError: { error in
>         if error.code != MessageComposerStore.errorMaxAttachmentsExceeded { report(error) }
>     },
>     onTextChanged: { text in log(text) }
> )
> ```
>
> `CometChatError` has a `code` and a `message`:
>
> | `code` | When |
> | - | - |
> | the SDK's code, or `SEND_ERROR` | a text, media, sticker or batch send failed |
> | the SDK's code, or `EDIT_ERROR` | an edit failed |
> | `FILE_ERROR` | a file to send is missing or empty |
> | the SDK's code, or `UPLOAD_ERROR` | an upload could not start, or the server rejected a file |
> | `MAX_ATTACHMENTS_EXCEEDED` | the tray is full, or a pick was trimmed |
> | `MEDIA_SELECTION_ERROR` | a picker failed, or there is no camera |
> | `RECORDING_ERROR` | no microphone permission, or an empty recording |
> | `ERR_EXTENSION_NOT_ENABLED` | the sticker keyboard's extension is off |
> | `ERR_NO_RECEIVER`, `ERR_DOCUMENT_CREATION`, `ERR_WHITEBOARD_CREATION` | a collaborative document or whiteboard could not be created |
>
> A failed retry stays on its tile and does not reach `onError`.

> [tab] UIKit
>
> | Setter | Signature | Called |
> | - | - | - |
> | `set(onSendButtonClick:)` | `(String) -> Void` | after a text or attachment send, with the markdown; not for edits |
> | `set(onError:)` | `(CometChatException) -> Void` | every error — twice for a failed send |
> | `set(onTextChangedListener:)` | `(String) -> Void` | every edit, with the whole plain text |
> | `set(onCameraClick:)` … `set(onCollaborativeWhiteboardClick:)` | `() -> Bool` | an option was picked; `true` skips the default |
> | `set(onAttachmentOptionClick:)` | `(ComposerAttachmentOption) -> Void` | a custom option was picked |
> | `set(onVoiceRecordingClick:)` | `() -> Void` | after the recorder was asked to start |
> | `set(onAIClick:)` | `() -> Void` | the AI button |
> | `set(onStickerClick:)` | `() -> Void` | after the sticker keyboard toggled |
> | `set(onStickerSelected:)` | `(Sticker) -> Void` | after the sticker was sent |
> | `set(onAttachmentClick:)` | `() -> Void` | never |
>
> The error's code is the SDK's, or `SEND_ERROR`, `EDIT_ERROR`, `FILE_ERROR`,
> `UPLOAD_ERROR`, `MAX_ATTACHMENTS_EXCEEDED`, `RECORDING_ERROR`, `MEDIA_SELECTION_ERROR`,
> `ERR_NO_RECEIVER`, `ERR_POLL_CREATION`, `ERR_DOCUMENT_CREATION` or
> `ERR_WHITEBOARD_CREATION`.
>
> ```swift theme={null}
> composer.set(onError: { error in
>     if error.errorCode == "MAX_ATTACHMENTS_EXCEEDED" { return }
>     log(error)
> })
> ```

### Global Events

The composer listens to the Kit's message and UI events, and only to those addressed to its
own chat and thread.

> [tab] SwiftUI
>
> | Event it reacts to | Effect |
> | - | - |
> | `.messageEdited(status: .inProgress)`, a text or media message | enter edit mode |
> | `.replyToMessage(status: .inProgress)` | enter reply mode |
> | `.replyToMessage(status: .success)` | leave reply mode |
> | `.composeMessage(id:text:)` | put the text in the input |
> | `.agentChatThreadResolved` | in an agent chat, continue in that thread |
>
> `ComposeMessage` is how conversation starters and smart replies reach the input. Emit it
> yourself with the user's uid or the group's guid:
>
> ```swift theme={null}
> CometChatEvents.emitUIEvent(.composeMessage(id: "alice", text: "Can we meet at 5?"))
> ```
>
> > [!NOTE]
> >
> > `ComposeMessage` is matched on the uid or guid only, so a composer in a thread of that
> > chat takes the text as well.
>
> | Event it emits | When |
> | - | - |
> | `.messageSent` `.inProgress`, then `.success` or `.error` | every text, media, voice note, sticker and batch message — `.inProgress` as the send starts |
> | `.replyToMessage(message: sent, status: .success)` | after **every** successful send, replying or not |
> | `.replyToMessage(message: repliedTo, status: .success)` | after a poll, document or whiteboard, only when replying |
> | `.messageEdited` `.success` or `.error` | when an edit completes |
>
> ```swift theme={null}
> .onCometChatMessageSent { message, status in
>     if status == .error { log("failed \(message.muid)") }
> }
> ```
>
> A message sent in a thread follows the thread, when thread subscription is on. The
> follow is applied twice per send, so `.subscriptionChanged` can arrive twice. See
> [Events](https://www.cometchat.com/docs/ui-kit/ios/v6/events.md) for the whole bus.

> [tab] UIKit
>
> | Event | Effect |
> | - | - |
> | `ccMessageEdited` in progress | enters edit mode |
> | `ccReplyToMessage` in progress | enters reply mode |
> | `ccComposeMessage(id:text:)` | sets the input — matched on the receiver id only, not the thread |
> | `ccAgentChatThreadResolved` | agent chat continues in that thread |
>
> And announces what it does, as the message list expects: `ccMessageSent` for every
> message — in progress as the send starts, before `set(onSendButtonClick:)` is called —
> `ccMessageEdited` when an edit completes, and `ccReplyToMessage` with success after
> **every** send, replying or not. See [Events](https://www.cometchat.com/docs/ui-kit/ios/v6/events.md).

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

The composer registers no SDK listeners of its own. The message list shows what it sends
through the Kit's events.

### Typing Indicators

Typing sends a typing indicator. Nothing is sent to a user who has blocked you, or whom you
have blocked.

> [tab] SwiftUI
>
> Each keystroke restarts a one-second timer, and the indicator ends when the timer runs out,
> on send, or when the composer disappears. Moving the caret or the selection also counts as
> typing. `disableTypingEvents: true` turns indicators off. To decide per keystroke, give the
> store a [policy](#store-access).

> [tab] UIKit
>
> The indicator ends after a second without typing, on send, and when the composer leaves the
> window. `disableTypingEvents = true` sends none.

***

## Functionality

> [tab] SwiftUI
>
> Data and behaviour parameters:
>
> | Parameter | Type | Default |
> | - | - | - |
> | `user` | `CometChatSDK.User?` | `nil` |
> | `group` | `CometChatSDK.Group?` | `nil` |
> | `parentMessageId` | `Int` | `-1` |
> | `store` | `MessageComposerStore?` | `nil` |
> | `enableMultipleAttachments` | `Bool` | `true` |
> | `enableRichTextFormatting` | `Bool` | `false` |
> | `enabledFormats` | `Set<RichTextFormat>` | `[]` |
> | `layoutMode` | `ComposerLayoutMode` | `.singleLine` |
> | `disableTypingEvents` | `Bool` | `false` |
> | `disableMentions` | `Bool` | `false` |
> | `placeholderText` | `String?` | `nil` |
> | `textFormatters` | `[any CometChatTextFormatter]?` | `nil` |
> | `attachmentOptions` | `[ComposerAttachmentOption]` | `[]` |
> | `disableSoundForMessages` | `Bool` | `false` — no effect |
> | `maxLines` | `Int` | `5` — the single-line input's line cap; no effect in multi-line |
>
> Visibility:
>
> | Parameter | Default | Hides |
> | - | - | - |
> | `hideAttachmentButton` | `false` | the attachment button and its menu |
> | `hideVoiceRecordingButton` | `false` | the mic |
> | `hideStickersButton` | `false` | the sticker button |
> | `hideAuxiliaryButton` | `false` | the sticker button **and** the mic |
> | `hideSendButton` | `false` | the send button |
> | `hideMessagePreview` | `false` | the reply preview — not the reply ([Edit and Reply](#edit-and-reply)) |
> | `hideCameraOption` … `hideFileOption` | `false` | a menu option |
> | `hidePollOption`, `hideCollaborativeDocumentOption`, `hideCollaborativeWhiteboardOption` | `true` | a menu option |
>
> ```swift theme={null}
> CometChatMessageComposer(
>     user: user,
>     hideVoiceRecordingButton: true,
>     hideStickersButton: true
> )
> ```
>
> The same elements can be hidden for a whole subtree:
>
> ```swift theme={null}
> MyAppRoot()
>     .cometChatMessageComposerHidden([.stickersButton, .voiceRecordingButton])
> ```
>
> A subtree can hide more than a composer's own flags, never less. So poll, document and
> whiteboard can only be shown through their flags.

> [tab] UIKit
>
> Properties:
>
> | Property | Type | Default |
> | - | - | - |
> | `hideAttachmentButton` | `Bool` | `false` |
> | `hideVoiceRecordingButton` | `Bool` | `false` |
> | `hideStickersButton` | `Bool` | `false` |
> | `hideAIButton` | `Bool` | `true` |
> | `hideImageAttachmentOption`, `hideVideoAttachmentOption`, `hideFileAttachmentOption` | `Bool` | `false` |
> | `hidePollsOption`, `hideCollaborativeDocumentOption`, `hideCollaborativeWhiteboardOption` | `Bool` | `true` |
> | `enableMultipleAttachments` | `Bool` | `true` |
> | `enableRichTextFormatting` | `Bool` | `true` |
> | `showRichTextFormattingOptions` | `Bool` | `false` |
> | `disableTypingEvents` | `Bool` | `false` |
> | `style` | `MessageComposerStyle` | a copy of `CometChatMessageComposer.style` |
> | `suggestionsStyle` | `SuggestionViewStyle` | `SuggestionViewStyle()` |
> | `mentionStyle` | `MentionTextStyle` | `MentionTextStyle()` |
> | `renderPath` | `RenderPath` | `.glass` |
> | `messageComposerStore` | `MessageComposerStore` | a store created for you |
> | `secondaryButtonView` | `((User?, Group?) -> UIView)?` | `nil` |
> | `set(placeholder:)` | `String` | "Type your message…" |
>
> Setters:
>
> | Setter | Value | Default |
> | - | - | - |
> | `set(user:)`, `set(group:)` | `CometChatSDK.User`, `CometChatSDK.Group` | — |
> | `set(parentMessageId:)` | `Int` | — |
> | `set(layoutMode:)` | `.singleLine` or `.multiLine` | `.singleLine` |
> | `set(showFormattingToolbar:)` | `Bool` | — |
> | `set(cameraOptionVisibility:)`, `set(audioOptionVisibility:)` | `Bool` | `true` |
> | `set(hideEditPreview:)`, `set(hideMessagePreview:)` | `Bool` | `false` |
> | `set(richTextConfiguration:)` | `RichTextConfiguration` | all off |
> | `set(showTextSelectionMenuItems:)` | `Bool` | `true` |
> | `set(textFormatter:)` | `[any CometChatTextFormatter]` — appended | — |
> | `set(suggestionListMaxHeight:)` | `CGFloat` | `200` |
> | `show(suggestionListAvatar:)` | `Bool` | `true` |
> | `set(attachmentOptions:)`, `add(attachmentOption:)` | `ComposerAttachmentOption` — appended | — |
>
> In agent chat the attachment, microphone and sticker flags stay `true` whatever you set.

***

## Custom View Slots

> [tab] SwiftUI
>
> | Slot | Receives | Replaces |
> | - | - | - |
> | `headerView` | — | adds a view above the input |
> | `footerView` | — | adds a view below the input, above the sticker keyboard |
> | `sendButtonView` | `onClick`, `isActive`, `isAIGenerating` | the send circle |
> | `secondaryButtonView` | `onAttachmentClick`, `onVoiceRecordClick` | the `+` circle **and** its menu |
> | `auxiliaryButtonView` | the SDK `User?` and `Group?`, and the id map | the mic, in the mic's circle. The sticker button stays in the input |
> | `editPreviewView` | the `BaseMessage` being edited, `onClose` | the edit preview |
> | `replyPreviewView` | the `BaseMessage` being replied to, `onClose` | the reply preview |
> | `trailingToolbarContent` | `ComposerInputController` | adds to the end of the formatting toolbar |
>
> ```swift theme={null}
> CometChatMessageComposer(
>     user: user,
>     headerView: { AnyView(MyComposerHint()) },
>     editPreviewView: { message, onClose in AnyView(MyEditBanner(message, onClose: onClose)) },
>     replyPreviewView: { message, onClose in AnyView(MyReplyBanner(message, onClose: onClose)) }
> )
> ```
>
> Call `onClose` to leave edit or reply mode, with the same effect as the default ✕.
>
> In single-line layout, a custom `sendButtonView` or `secondaryButtonView` is drawn **bare**,
> with no circle behind it, at its own width. It is 40 pt high, and its tap target is at least
> 44 pt. A custom `auxiliaryButtonView` is drawn in the mic's circle, in the mic's place,
> at least 40 pt wide; the sticker button stays inside the input. `hideAuxiliaryButton` hides
> the sticker button, the mic and the custom view together.
>
> ```swift theme={null}
> CometChatMessageComposer(
>     group: group,
>     auxiliaryButtonView: { user, group, _ in AnyView(MyGifButton(user: user, group: group)) }
> )
> ```
>
> > [!WARNING]
> >
> > The Kit does not gate a custom `sendButtonView`'s `onClick` on `isActive`. While files
> > are still uploading, a tap sends the text as a plain message, clears the input and
> > leaves the tiles. Check `isActive` yourself.
> >
> > A custom `secondaryButtonView` replaces the menu too: calling its `onAttachmentClick`
> > shows nothing. Its `onVoiceRecordClick` opens the recorder.
>
> ```swift theme={null}
> CometChatMessageComposer(
>     user: user,
>     secondaryButtonView: { _, onVoiceRecordClick in
>         AnyView(Button("Voice", systemImage: "mic", action: onVoiceRecordClick))
>     }
> )
> ```
>
> Every slot is also a modifier, for every composer in a subtree. An initialiser argument
> wins. The modifier forms of the two preview slots and the auxiliary slot receive the
> Kit's value types — a `ComposerMessagePreview` (`title`, `text`, `mediaKind`) and
> `ChatUser?` / `ChatGroup?` — rather than SDK objects:
>
> ```swift theme={null}
> MyAppRoot()
>     .cometChatMessageComposerHeaderView { MyComposerHint() }
>     .cometChatMessageComposerReplyPreviewView { preview, onClose in
>         HStack {
>             Text(preview.title)
>             Button("Cancel", action: onClose)
>         }
>     }
> ```

> [tab] UIKit
>
> Each slot is `(User?, Group?) -> UIView`, re-run on `set(user:)` / `set(group:)`:
>
> | Slot | Replaces |
> | - | - |
> | `set(headerView:)` | adds a view above the composer |
> | `set(footerView:)` | adds a view under the compose box, above the sticker keyboard |
> | `set(sendButtonView:)` | the send circle |
> | `set(auxillaryButtonView:)` *(spelt as shown)* | the AI and microphone buttons, in the microphone's circle. The sticker button stays in the input |
> | `secondaryButtonView` | the `+` circle |
> | `set(richTextToolbarTrailingView:)` | adds a view after the toolbar's buttons |
>
> Setting any one slot re-runs every slot, so return a view you keep, or build a fresh one
> each time. A replaced button does nothing by itself — call the composer's override point
> from it:
>
> ```swift theme={null}
> composer.set(sendButtonView: { [weak composer] _, _ in
>     UIButton(type: .system, primaryAction: UIAction(title: "Send") { _ in
>         composer?.didSendButtonClicked()
>     })
> })
> composer.secondaryButtonView = { [weak composer] _, _ in
>     UIButton(type: .system, primaryAction: UIAction(image: UIImage(systemName: "paperclip")) { _ in
>         composer?.attachmentButtonClicked()
>     })
> }
> composer.set(headerView: { user, _ in
>     MyComposerBanner(text: "Replying to \(user?.name ?? "the group")")
> })
> ```
>
> A custom send button is not disabled for you while attachments upload or an agent is
> generating.
>
> In single-line layout, a custom send or secondary view is drawn **bare**, with no circle
> behind it, at its own width. It is 40 pt high, and its tap target is at least 44 pt. A custom
> auxiliary view is drawn in the microphone's circle, in the microphone's place, at least 40 pt
> wide; the sticker button stays inside the input. `hideStickersButton` and
> `hideVoiceRecordingButton` work as before: the first hides the sticker button, the second does
> not hide a custom auxiliary view.

***

## Advanced Methods

### Data Methods

> [tab] SwiftUI
>
> SwiftUI has no composer methods. Drive the composer through its store — see
> [Store Access](#store-access).

> [tab] UIKit
>
> | Method | Purpose |
> | - | - |
> | `set(text:)` / `text` | replace / read the input's plain text |
> | `sendMediaMessage(url:contentType:)` | send a file at once |
> | `edit(message:)`, `set(editMessage:)`, `exitEditMode()` | edit mode |
> | `reply(message:)`, `exitReplyMode()` | reply mode |
> | `showStickerKeyboard()`, `hideStickerKeyboard()`, `toggleStickerKeyboard()` | the sticker keyboard |
> | `isStickerKeyboardVisible`, `isRichTextToolbarVisible`, `isFormattingToolbarVisible` | read state |
> | `textFormatters`, `layoutMode`, `showTextSelectionMenuItems` | read configuration |
> | `bottomPanelLayout` | the panel that hosts the sticker keyboard |

### Subclassing

> [tab] SwiftUI
>
> The SwiftUI composer is customised through parameters, modifiers and a store; there is
> nothing to subclass.

> [tab] UIKit
>
> The class is `open`. These are its override points:
>
> | Method | Called |
> | - | - |
> | `buildUI()` | once, to build the view tree |
> | `setupStyle()` | when the style, theme, text size or window changes |
> | `handleThemeModeChange()` | once, to register for light and dark changes |
> | `didSendButtonClicked()` | the send button — sends when there is text or attachments |
> | `didDefaultSendButtonClicked()` | the send itself |
> | `didMicrophoneButtonClicked()` | the microphone — opens the recorder |
> | `attachmentButtonClicked()` | the attachment button — opens the sheet |
> | `didStickersButtonClicked()` | the sticker button — toggles the keyboard, then `onStickerClick` |
> | `presentEditPreview(for:)` / `hideEditPreview()` | the edit preview |
> | `setupAuxiliaryButton()` | embeds a custom auxiliary view |
> | `handleWindowSizeTransition(to:with:)` | relays out for a window resize — call it from your view controller |
>
> Call `super` unless you replace the behaviour on purpose.
>
> ```swift theme={null}
> final class BrandedComposer: CometChatMessageComposer {
>     private let badge = UILabel()
>
>     override func buildUI() {
>         super.buildUI()
>         badge.font = .preferredFont(forTextStyle: .caption2)
>         badge.text = "Encrypted"
>         set(footerView: { [badge] _, _ in badge })
>     }
>
>     override func presentEditPreview(for message: BaseMessage) {
>         super.presentEditPreview(for: message)
>         badge.text = "Editing"
>     }
>
>     override func hideEditPreview() {
>         super.hideEditPreview()
>         badge.text = "Encrypted"
>     }
> }
> ```

### Store Access

> [tab] SwiftUI
>
> Every composer has a `MessageComposerStore`. Pass your own to reach it:
>
> ```swift theme={null}
> struct DraftComposer: View {
>     let user: CometChatSDK.User
>     @State private var store = MessageComposerStore(policy: ComposerPolicy(
>         startTyping: { store in
>             if !store.hasStagedAttachments { store.defaultStartTyping() }
>         }
>     ))
>
>     var body: some View {
>         CometChatMessageComposer(user: user, store: store)
>             .onAppear { store.setComposeText("Hi! ") }
>     }
> }
> ```
>
> | Store member | Use |
> | - | - |
> | `setComposeText(_:)` | put text in the input — it replaces the first block of text |
> | `setEditMessage(_:)`, `clearEditMessage()` | enter and leave edit mode |
> | `setReplyMessage(_:)`, `clearReplyMessage()` | enter and leave reply mode |
> | `editMessage`, `replyMessage`, `isAIGenerating`, `attachmentTiles`, `uiState` | read the current state; all observable |
> | `maxAttachmentCount` | the attachment cap, read-only |
> | `errorEvent` | every error, as an `AsyncStream` |
> | `policy` | `ComposerPolicy` — the `startTyping` and `endTyping` hooks; call `defaultStartTyping()` / `defaultEndTyping()` for the Kit's behaviour |
>
> The composer sets the store's user, group and thread when it appears, and starts it then.
> An event emitted before the composer first appears is not seen.
>
> A seeded store has fixed values and sends, uploads and listens to nothing:
>
> ```swift theme={null}
> #Preview {
>     CometChatMessageComposer(user: user, store: MessageComposerStore(seeded: .idle))
> }
> ```

> [tab] UIKit
>
> `messageComposerStore` is the `MessageComposerStore` behind the composer — pass one to
> share it, or to render fixed state with no session:
>
> ```swift theme={null}
> let preview = CometChatMessageComposer(messageComposerStore: MessageComposerStore(seeded: .idle))
> let live = CometChatMessageComposer(messageComposerStore: MessageComposerStore())
> ```
>
> A seeded store is inert: nothing is sent. Option visibility and custom options live in
> the store, so set them after replacing it.

### Objective-C

In the UIKit toolkit:

The composer is `@objc`. Fluent setters take Swift's `set(user:)` as `setWithUser:`;
callbacks keep their names:

```objc theme={null}
CometChatMessageComposer *composer = [[CometChatMessageComposer alloc] init];
[[composer setWithUser:user] setWithPlaceholder:@"Message"];
composer.hidePollsOption = NO;
[composer setOnSendButtonClick:^(NSString *text) { NSLog(@"sent %@", text); }];
[composer setOnError:^(CometChatException *error) { NSLog(@"%@", error.errorCode); }];

CometChatMessageComposerStyle *style = [[CometChatMessageComposerStyle alloc] init];
style.activeSendButtonBackgroundColor = UIColor.systemIndigoColor;
[composer setWithStyle:style];
```

In Objective-C the separate styles are `CometChatSuggestionViewStyle`,
`CometChatMentionTextStyle` and `CometChatRichTextToolbarStyle`. **Swift only**, because
their types are: `messageComposerStore`, `renderPath`, `set(layoutMode:)` / `layoutMode`,
`set(richTextConfiguration:)`, `set(textFormatter:)` / `textFormatters`,
`set(attachmentOptions:)`, `add(attachmentOption:)`, `set(onAttachmentOptionClick:)`,
`set(onStickerSelected:)`, `secondaryButtonView` and `set(richTextToolbarTrailingView:)`.

***

## Accessibility

> [tab] SwiftUI
>
> * The composer supports Dynamic Type up to the largest accessibility sizes, VoiceOver and
>   right-to-left layouts.
> * Formatting-toolbar buttons have 44 pt hit areas.
> * A staged file reads as one element. Its tap is the default action and its ✕ is a named
>   action (Cancel or Remove). A rejected file's reason is announced.
> * A reply to a media message reads its kind first — "Video, clip.mp4".
> * The recorder's time grows with Dynamic Type. Under Reduce Motion the recording dot does
>   not pulse and the sticker keyboard fades in and out instead of sliding. The recorder
>   slides out the correct way in right-to-left.
> * The send button's VoiceOver labels — "Send message", "Send button disabled", "AI is
>   generating" — and the selection menu's four format titles are English in every language.

> [tab] UIKit
>
> The row mirrors in a right-to-left layout, and the input's text scales with Dynamic Type.

***

## Style

> [tab] SwiftUI
>
> `CometChatMessageComposerStyle` is sparse: set only what you change, and everything else
> follows the theme.
>
> ```swift theme={null}
> var style = CometChatMessageComposerStyle()
> style.composeBoxCornerRadius = 20
> style.sendButtonActiveBackgroundColor = .indigo
> style.inputTextStyle = .preferredFont(forTextStyle: .callout)
>
> CometChatMessageComposer(user: user, style: style)
> ```
>
> For every composer — and every other component — set the theme at the root:
>
> ```swift theme={null}
> MyApp()
>     .cometChatTheme(brandTheme)
> ```
>
> | Property | Default |
> | - | - |
> | `backgroundColor` | Fills **every** single-line shape but send: `+`, the input, the mic circle, the toolbar, the preview and tray cards, and the recorder's bin and capsule. Set, it **replaces the glass** on iOS 26. Unset: glass on iOS 26, `background1` on iOS 18–25. In multi-line it is the outer container (`background3`, `background2` in dark) |
> | `strokeColor`, `strokeWidth` | An outline around **each** shape separately, the toolbar and the send circle included. Unset: a `strokeDefault` hairline on iOS 18–25, none on glass and none on the send circle |
> | `cornerRadius` | Each shape's corner. `nil`, the default, is fully round; an input taller than one line keeps a 20-pt corner. The cards are 16 |
> | `composeBoxBackgroundColor`, `…StrokeColor`, `…StrokeWidth`, `…CornerRadius` | The input capsule only, ahead of the values above. In multi-line: the rounded box around the input, `background1`, `strokeDefault`, 1, 8 |
> | `separatorColor` | `strokeLight`: the formatting toolbar's border, ahead of `strokeColor` for the toolbar only, and the multi-line row's divider. Not drawn on glass. No line is drawn above the composer |
> | `inputTextColor`, `inputTextStyle` | `textPrimary`, `bodyRegular` (14 pt) — a `UIFont`, scaled with Dynamic Type |
> | `inputPlaceholderColor`, `inputPlaceholderStyle` | `textTertiary`, `bodyRegular` |
> | `attachmentIcon`, `voiceRecordingIcon`, `stickerIcon`, `stickerActiveIcon` (+ `…Tint`) | the glyphs, 20 pt: `plus` in the `+` circle in single-line (`plus.circle` in multi-line), `mic` in the mic circle and the Kit's sticker image inside the input, in `iconTintSecondary`; the open sticker button in `primary` |
> | `aiIcon`, `aiIconTint` | the Kit's AI image in `iconTintSecondary` — the button is not shown in this toolkit |
> | `sendButtonActiveIcon`, `sendButtonInactiveIcon`, `sendButtonStopIcon`, `sendButtonIconTint` | the Kit's send and stop images. The send glyph is white with or without something to send (multi-line: `primaryButtonIconTint`, white in both appearances) |
> | `sendButtonActiveBackgroundColor`, `sendButtonInactiveBackgroundColor` | `primary`; inactive `neutral300` in single-line, `background4` in multi-line. A solid circle on every path, never glass; `backgroundColor` does not change it. In agent chat, while unset, the circle shows an up arrow: `neutral900` with a `neutral50` arrow when active, the other shapes' surface with an `iconTintSecondary` arrow when inactive (multi-line: `neutral900` / `neutral300`); the stop button stays `primary` |
> | `editPreview…` (10) | title `bodyRegular` `textPrimary`, text `caption1Regular` `textSecondary`, close `xmark` in `iconTintHighlight`. Single-line: the card's surface, 16-pt corner; multi-line: background `background3`, corner 4, no border |
> | `messagePreview…` (11) | the reply preview: title `caption1Medium` `textHighlight`, text `caption1Regular` `textSecondary`, a `strokeHighlight` bar, close `xmark` in `iconTintSecondary`. Single-line: the card's surface, 16-pt corner; multi-line: background `background3`, corner 4, no border |
> | `infoIcon`, `infoIconTint`, `infoTextColor`, `infoTextStyle`, `infoBackgroundColor`, `infoCornerRadius`, `infoStrokeColor`, `infoStrokeWidth` | the mention-limit row: `info.circle` and text in `error`, `caption1Regular`, `background2`, square, no border |
> | `richTextToolbarBackgroundColor`, `…IconTint`, `…ActiveIconTint`, `…ActiveIconBackgroundColor` | the toolbar capsule's surface (`background2` in multi-line), `iconTintSecondary`, `textPrimary`, `background4`. A set background replaces the glass |
> | `richTextToggleIcon`, `…Tint`, `…ActiveTint`; `formattingToolbarCloseIcon`, `…Tint` | the multi-line **Aa** and ✕ |
>
> The link popup is the system alert, and the Add / Edit Link dialog is drawn as one — the
> same size, glass, fields and buttons, in light and dark, at every text size. Neither takes
> styling.
>
> The parts the composer hosts have their own style parameters:
>
> | Parameter | Styles |
> | - | - |
> | `attachmentPopupStyle: PopupMenuStyle` | the attachment menu's sheet |
> | `attachmentTrayStyle: CometChatAttachmentTrayStyle` | the tray — background, padding, spacing |
> | `attachmentTileStyle: CometChatAttachmentTileStyle` | the tiles — size, corners, progress, retry, file cards, audio |
> | `attachmentErrorAlertStyle: CometChatErrorAlertStyle` | a rejected file's reason |
> | `suggestionListStyle: CometChatSuggestionListStyle` | the mention list — 200 pt tall at most by default |
> | `stickerKeyboardStyle: CometChatStickerKeyboardStyle` | the [sticker keyboard](https://www.cometchat.com/docs/ui-kit/ios/v6/sticker-keyboard.md#style) |
>
> ```swift theme={null}
> var tile = CometChatAttachmentTileStyle()
> tile.mediaCornerRadius = 12
> var suggestions = CometChatSuggestionListStyle()
> suggestions.maxHeight = 180
>
> CometChatMessageComposer(
>     group: group,
>     attachmentTileStyle: tile,
>     suggestionListStyle: suggestions
> )
> ```
>
> > [!NOTE]
> >
> > The composer always sets three `attachmentPopupStyle` fields itself — `cornerRadius` 16,
> > `itemPaddingVertical` 12, `startIconTint` `iconTintHighlight` — and the sheet has nothing
> > to apply `elevation`, `minWidth` or `endIconTint` to.

> [tab] UIKit
>
> Style precedence:
>
> ```
> instance style  >  CometChatMessageComposer.style  >  theme  >  Kit default
> ```
>
> The static style is the default every composer created **afterwards** copies — set it
> before creating composers:
>
> ```swift theme={null}
> CometChatMessageComposer.style.activeSendButtonBackgroundColor = .systemIndigo
> CometChatMessageComposer.style.composeBoxCornerRadius = 20
> CometChatUIKitTheme.shared.setBrandColor(.systemIndigo)
> ```
>
> For one composer:
>
> ```swift theme={null}
> let style = MessageComposerStyle()
> style.textFieldColor = .label
> style.placeholderColor = .tertiaryLabel
> style.composeBoxBorderColor = .separator
> style.richTextToolbarStyle.activeIconTintColor = .systemIndigo
> composer.set(style: style)
> ```
>
> Assigning `style` applies it. Changing a property of `composer.style` in place is not
> applied until the next theme change — assign a style instead.
>
> In single-line layout `+`, the input, the microphone circle and the toolbar are Liquid Glass
> on iOS 26. On iOS 18–25, and with Reduce Transparency on, the same shapes take the theme's
> solid fill with a hairline outline. The send circle is solid on every path, with no outline,
> and never glass. A `backgroundColor` you set fills every shape but send and replaces the
> glass. `renderPath = .fallback` forces the opaque look. In multi-line the
> container is glass on iOS 26 and `backgroundColor` applies only when opaque.
>
> Sizes are "unset" until you assign them: `cornerRadius` and `composeBoxCornerRadius` default
> to `-1`, which is fully round (`0` is square, a positive value that radius). `borderWidth`,
> `composeBoxBorderWidth` and the preview radii and border widths keep each shape's default
> until you set them: an explicit `0` means no border.
>
> Unset colours and fonts follow `CometChatUIKitTheme`. The link popup is the system alert and
> the link dialog is drawn as one; neither takes styling.
>
> | Property | Default |
> | - | - |
> | `backgroundColor` | Fills **every** single-line shape but send: `+`, the input, the microphone circle, the toolbar and the preview and tray cards. Set, it **replaces the glass** on iOS 26. Unset: glass on iOS 26, `background1` on iOS 18–25. In multi-line it is the container (`background3`, `background2` in dark) |
> | `borderColor`, `borderWidth` | An outline around **each** shape separately, the toolbar and the send circle included. Unset: a `strokeDefault` hairline on iOS 18–25, none on glass and none on the send circle; `0` is no border |
> | `cornerRadius` | Each shape's corner. `-1`, the default, is fully round; an input taller than one line keeps a 20-pt corner. The cards are 16 |
> | `composeBoxBackgroundColor`, `composeBoxBorderColor`, `composeBoxBorderWidth`, `composeBoxCornerRadius` | The input capsule only, ahead of the values above. In multi-line: the box around the input, `background1`, `strokeDefault`, 1, 8 |
> | `composerSeparatorColor` | `strokeLight`: the formatting toolbar's border, ahead of `borderColor` for the toolbar only, and the multi-line row's divider. Not drawn on glass. No line is drawn above the composer |
> | `textFieldColor`, `textFieldFont`, `placeholderColor`, `placeholderFont` | `textPrimary`, `bodyRegular` (14 pt, scaled with Dynamic Type), `textTertiary`, the input's font |
> | `attachmentImage`, `voiceRecordingImage`, `aiImage`, `stickersImage` (+ `…Tint`) | the glyphs, 20 pt: `plus` in the `+` circle in single-line (`plus.circle` in multi-line), `mic` and the Kit's AI image in the microphone circle, the Kit's sticker image inside the input, in `iconTintSecondary` |
> | `stickerActiveIcon`, `stickersActiveImageTint` | the same sticker image, `primary` — while the keyboard is open |
> | `sendButtonImage`, `sendButtonInactiveIcon`, `sendButtonImageTint`, `sendButtonStopIcon` | the Kit's send and stop images. In single-line the send glyph is 20 pt and white with or without something to send (multi-line: `primaryButtonIconTint`, white in both appearances) |
> | `activeSendButtonBackgroundColor`, `inactiveSendButtonBackgroundColor` | `primary`; inactive `neutral300` in single-line, `background4` in multi-line. A solid circle on every path, never glass; `backgroundColor` does not change it. In agent chat, while unset, the circle shows an up arrow: `neutral900` with a `neutral50` arrow when active, the other shapes' surface with an `iconTintSecondary` arrow when inactive (multi-line: `neutral900` / `neutral300`); the stop button stays `primary` |
> | `editPreview…` — title, message, background, border, corner, close icon | `bodyRegular` `textPrimary`, `caption1Regular` `textSecondary`, `xmark` in `iconTintHighlight`. Single-line: the card's surface, 16-pt corner; multi-line: `background3`, none, 4 |
> | `preview…` — the reply preview; `messagePreviewSeparatorColor` its bar | title `caption1Medium` `textHighlight`, text `caption1Regular` `textSecondary`, bar `strokeHighlight`. Single-line: the card's surface, 16-pt corner; multi-line: `background3`, none, 4 |
> | `infoIcon`, `infoIconTint`, `infoTextColor`, `infoTextFont`, `infoBackgroundColor`, `infoCornerRadius`, `infoBorderColor`, `infoBorderWidth` | the mention-limit row: `info.circle` and text in `error`, `caption1Regular`, `background2`, 0, none, 0 |
> | `richTextToolbarStyle` — `backgroundColor`, `iconTintColor`, `activeIconTintColor`, `activeButtonBackgroundColor` | the toolbar capsule's surface (`background2` in multi-line), `iconTintSecondary`, `textPrimary`, `background4`. A set background replaces the glass |
> | `richTextToolbarToggleIcon`, `richTextToolbarToggleIconTint`, `richTextToggleIconActiveTint` | **Aa**: the Kit's image, `iconTintSecondary`, `primary` |
> | `formattingToolbarCloseIcon`, `formattingToolbarCloseIconTint` | the multi-line ✕: the Kit's image at 24 pt, `iconTintSecondary` |
>
> In single-line layout `sendButtonInactiveIcon` is the send circle's glyph with nothing to
> send. In multi-line it shows only until the send button's next state change.
>
> The separate styles:
>
> | Style | Property | Styles |
> | - | - | - |
> | `SuggestionViewStyle` | `suggestionsStyle` | the mention list: background, border, corner, row text and info text |
> | `MentionTextStyle` | `mentionStyle` | a mention in the input in `primary`, and a mention of you in `warning`, with no background |
> | `StickerKeyboardStyle` | `set(stickerKeyboardStyle:)` | the sticker keyboard |
>
> ```swift theme={null}
> let mentions = MentionTextStyle()
> mentions.textColor = .systemIndigo
> mentions.loggedInUserTextColor = .systemOrange
> composer.mentionStyle = mentions
> ```
>
> `mentionStyle` applies to mentions inserted afterwards.
>
> | Need | Use |
> | - | - |
> | Brand colour everywhere | `CometChatUIKitTheme.shared.setBrandColor(_:)` |
> | Every composer looks different | `CometChatMessageComposer.style` |
> | One composer looks different | `set(style:)` |
> | Your own button | a view slot |
> | Change what a button does | a callback, or subclass and override |
> | The two-row composer | `set(layoutMode: .multiLine)` |

***

## Next Steps

> [card] [Create Poll](https://www.cometchat.com/docs/ui-kit/ios/v6/create-poll.md)
>
> The form the Poll option opens

> [card] [Sticker Keyboard](https://www.cometchat.com/docs/ui-kit/ios/v6/sticker-keyboard.md)
>
> The panel the sticker button opens

> [card] [Events](https://www.cometchat.com/docs/ui-kit/ios/v6/events.md)
>
> What the composer listens to and announces

> [card] [Message List](https://www.cometchat.com/docs/ui-kit/ios/v6/message-list.md)
>
> Show the messages the composer sends


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