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.

Where It Fits
Give it the chat’sUser 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.
MessageComposerStore, shared by both toolkits.
Quick Start
- SwiftUI
- UIKit

+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
neutral300circle with nothing to send, onprimaryonce 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.
+, 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.
- SwiftUI
- UIKit
The input grows up to 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.
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: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).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.
- SwiftUI
- UIKit
- 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
onErroronce.
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: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.- SwiftUI
- UIKit
From your own UI, call the store:Or emit the event, as the message list does: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.
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 instead.Rich Text
- SwiftUI
- UIKit
Formatting is off by default. The toolbar under the input shows only when

It shows only while the toolbar does. Do not keep the controller after the view goes.
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:
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.
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:Layout Mode
The composer has two layouts: the single-line row of shapes described in 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.- SwiftUI
- UIKit

maxLines has no
effect. In single-line mode it grows to maxLines lines.Two quirks come with multi-line mode:
- the second row’s attachment button and Aa ignore
hideAttachmentButtonand agent chat; - Aa opens the toolbar even with formatting off. Then its format buttons do nothing, but Link still opens the link dialog.
sendButtonView is drawn in the second row. secondaryButtonView and
auxiliaryButtonView are not drawn in multi-line mode.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.
- SwiftUI
- UIKit
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.
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:onMentionClick is called after a suggestion is inserted: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.Attachments
The attachment button opens the attachment menu, a sheet of options.- SwiftUI
- UIKit
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:true to skip the Kit’s default,
or false to run it after yours: onCameraClick, onImageClick, onVideoClick,
onAudioClick, onDocumentClick, onPollClick, onCollaborativeDocumentClick,
onCollaborativeWhiteboardClick.onAttachmentClick returning true stops the menu from opening at all.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.Custom Options
- SwiftUI
- UIKit
attachmentOptions are appended after the built-in ones. They cannot remove or
reorder those. A tap goes to onAttachmentOptionClick: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.The Tray
WithenableMultipleAttachments 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.
- SwiftUI
- UIKit

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:Polls
- SwiftUI
- UIKit
hidePollOption: false adds Poll. It opens
CometChatCreatePoll 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:Collaborative Document and Whiteboard
- SwiftUI
- UIKit
Document and whiteboard need the Collaborative Document and Collaborative Whiteboard
extensions enabled on your CometChat dashboard. A failure shows a toast and reaches
onError.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’sbackground1 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.
- SwiftUI
- UIKit
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:
If the microphone permission is refused, or the recording is empty,
- Recording — the time, a live waveform, pause and delete.
- Paused — resume, delete, send.
- Done — play back, seek on the waveform, resume, delete, send.

onError receives
RECORDING_ERROR and the recorder closes. onVoiceRecordingClick returning true keeps
the recorder closed, so you can record your own way:An error from the recording engine reaches
onError twice.Stickers
The sticker button opens the sticker keyboard (see Sticker Keyboard) 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.- SwiftUI
- UIKit
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.
onStickerClickreturningtruestops the button from opening the keyboard.
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.
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.

- SwiftUI
- UIKit
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.Actions and Events
Callback Methods
- SwiftUI
- UIKit
CometChatError has a code and a message:A failed retry stays on its tile and does not reach
onError.Global Events
The composer listens to the Kit’s message and UI events, and only to those addressed to its own chat and thread.- SwiftUI
- UIKit
ComposeMessage is how conversation starters and smart replies reach the input. Emit it
yourself with the user’s uid or the group’s guid:ComposeMessage is matched on the uid or guid only, so a composer in a thread of that
chat takes the text as well..subscriptionChanged can arrive twice. See
Events for the whole bus.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.- SwiftUI
- UIKit
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.Functionality
- SwiftUI
- UIKit
Data and behaviour parameters:The same elements can be hidden for a whole subtree: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.
Visibility:
Custom View Slots
- SwiftUI
- UIKit
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.ComposerMessagePreview (title, text, mediaKind) and
ChatUser? / ChatGroup? — rather than SDK objects:Advanced Methods
Data Methods
- SwiftUI
- UIKit
SwiftUI has no composer methods. Drive the composer through its store — see
Store Access.
Subclassing
- SwiftUI
- UIKit
The SwiftUI composer is customised through parameters, modifiers and a store; there is
nothing to subclass.
Store Access
- SwiftUI
- UIKit
Every composer has a
MessageComposerStore. Pass your own to reach it: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:
Objective-C
In the UIKit toolkit: The composer is@objc. Fluent setters take Swift’s set(user:) as setWithUser:;
callbacks keep their names:
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
- SwiftUI
- UIKit
- 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.
Style
- SwiftUI
- UIKit
CometChatMessageComposerStyle is sparse: set only what you change, and everything else
follows the theme.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:
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.Next Steps
Create Poll
The form the Poll option opens
Sticker Keyboard
The panel the sticker button opens
Events
What the composer listens to and announces
Message List
Show the messages the composer sends



