CometChatMessageComposer component enables users to write and send messages including text, images, videos, audio, files, and custom messages. It supports attachments, voice recording, stickers, mentions, and AI-powered features.

AI Agent Component Spec
AI Agent Component Spec
Where It Fits
CometChatMessageComposer is the input component for sending messages. It’s typically used within CometChatMessages alongside CometChatMessageHeader and CometChatMessageList.

Minimal Render

Actions and Events
Callback Props
onSendButtonClick
Fires when the send button is clicked. Use this to handle custom send actions.onTextChanged
Fires when the user types in the composer. Use this for typing indicators or text validation.onError
Fires when an error occurs while sending a message.Actions Reference
| Method | Description | Example |
|---|---|---|
set(onSendButtonClick:) | Triggered when send button is clicked | Custom send handling |
set(onTextChanged:) | Triggered when text changes | Typing indicators |
set(onError:) | Triggered when an error occurs | Show error alert |
set(user:) | Sets the user for direct messaging | Configure recipient |
set(group:) | Sets the group for group messaging | Configure group |
set(parentMessageId:) | Sets parent message for thread replies | Thread replies |
setInitialComposerText(_:) | Sets initial text in composer | Pre-fill message |
Custom View Slots
| Slot | Signature | Replaces |
|---|---|---|
headerView | (User?, Group?) -> UIView | Header above composer |
footerView | (User?, Group?) -> UIView | Footer below composer |
sendButtonView | (User?, Group?) -> UIView | Send button |
attachmentOptions | (User?, Group?, UIViewController?) -> [CometChatMessageComposerAction] | Attachment menu options |
headerView
Add a custom header above the composer.
CustomHeaderView as a custom UIView:
sendButtonView
Replace the default send button with a custom view.attachmentOptions
Customize the attachment menu options.Styling
Style Hierarchy
- Global styles (
CometChatMessageComposer.style) apply to all instances - Instance styles override global for specific instances
Global Level Styling
Instance Level Styling

Key Style Properties
| Property | Type | Default | Description |
|---|---|---|---|
backgroundColor | UIColor | CometChatTheme.backgroundColor01 | Background color |
borderWidth | CGFloat | 0 | Border width |
borderColor | UIColor | .clear | Border color |
cornerRadius | CometChatCornerStyle? | nil | Corner radius |
placeHolderTextFont | UIFont | CometChatTypography.Body.regular | Placeholder font |
placeHolderTextColor | UIColor | CometChatTheme.textColorTertiary | Placeholder color |
textFiledColor | UIColor | CometChatTheme.textColorPrimary | Input text color |
textFiledFont | UIFont | CometChatTypography.Body.regular | Input text font |
sendButtonImage | UIImage? | System send icon | Send button icon |
sendButtonImageTint | UIColor | CometChatTheme.white | Send button tint |
activeSendButtonImageBackgroundColor | UIColor | CometChatTheme.primaryColor | Active send button background |
inactiveSendButtonImageBackgroundColor | UIColor | CometChatTheme.neutralColor300 | Inactive send button background |
composeBoxBackgroundColor | UIColor | CometChatTheme.backgroundColor01 | Compose box background |
composeBoxBorderColor | UIColor | CometChatTheme.borderColorDefault | Compose box border color |
composeBoxBorderWidth | CGFloat | 1 | Compose box border width |
attachmentImage | UIImage? | System plus icon | Attachment button icon |
attachmentImageTint | UIColor | CometChatTheme.iconColorSecondary | Attachment icon tint |
voiceRecordingImage | UIImage? | System mic icon | Voice recording icon |
voiceRecordingImageTint | UIColor | CometChatTheme.iconColorSecondary | Voice recording tint |
Customization Matrix
| What to change | Where | Property/API | Example |
|---|---|---|---|
| Background color | Style | backgroundColor | UIColor.systemBackground |
| Send button color | Style | activeSendButtonImageBackgroundColor | UIColor.systemBlue |
| Input text style | Style | textFiledColor, textFiledFont | Custom colors and fonts |
| Compose box look | Style | composeBoxBackgroundColor, composeBoxBorderColor | Custom styling |
| Attachment icon | Style | attachmentImage, attachmentImageTint | Custom icon |
| Hide attachment | Property | hideAttachmentButton | composer.hideAttachmentButton = true |
| Hide voice recording | Property | hideVoiceRecordingButton | composer.hideVoiceRecordingButton = true |
| Custom send button | View Slot | set(sendButtonView:) | See Custom View Slots |
Props
All props are optional. Sorted alphabetically.disableMentions
Disables the @mention feature in the composer.| Type | Bool |
| Default | false |
disableSoundForMessages
Disables sound when sending messages.| Type | Bool |
| Default | false |
disableTypingEvents
Disables sending typing indicators when the user types.| Type | Bool |
| Default | false |
hideAttachmentButton
Hides the attachment button.| Type | Bool |
| Default | false |
hideAudioAttachmentOption
Hides the audio attachment option.| Type | Bool |
| Default | false |
hideCollaborativeDocumentOption
Hides the collaborative document option.| Type | Bool |
| Default | false |
hideCollaborativeWhiteboardOption
Hides the collaborative whiteboard option.| Type | Bool |
| Default | false |
hideFileAttachmentOption
Hides the file attachment option.| Type | Bool |
| Default | false |
hideImageAttachmentOption
Hides the image attachment option.| Type | Bool |
| Default | false |
hidePollsOption
Hides the polls option.| Type | Bool |
| Default | false |
hideSendButton
Hides the send button.| Type | Bool |
| Default | false |
hideStickersButton
Hides the stickers button.| Type | Bool |
| Default | false |
hideVideoAttachmentOption
Hides the video attachment option.| Type | Bool |
| Default | false |
hideVoiceRecordingButton
Hides the voice recording button.| Type | Bool |
| Default | false |
maxLine
Sets the maximum number of lines for the composer input before scrolling.| Type | Int |
| Default | 5 |
textFormatters
Array of text formatters for customizing text display (e.g., mentions).| Type | [CometChatTextFormatter] |
| Default | [] |
Events
The MessageComposer component does not emit any global UI events.Troubleshooting
| Issue | Solution |
|---|---|
| Send button not working | Ensure user or group is set on the composer |
| Attachments not showing | Check that attachment options are not hidden |
| Voice recording not working | Verify microphone permissions are granted |
| Mentions not working | Ensure disableMentions is not set to true |
| Typing indicators not sent | Check that disableTypingEvents is not set to true |
Related Components
- Message List - Display messages in a conversation
- Message Header - Display user/group details
- Messages - Parent component containing MessageComposer
- Mentions Formatter - Configure @mention formatting