Skip to main content
The 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.

Where It Fits

CometChatMessageComposer provides a rich text input with attachment, emoji, voice recording, sticker, and send controls. Wire it alongside CometChatMessageHeader and CometChatMessageList to build a standard chat view.

Minimal Render


Actions and Events

Callback Props

onSendButtonClick

Fires when the send button is clicked. Overrides the default send behavior.

onTextChangedListener

Fires as the user types in the composer input.

onError

Fires on internal errors.

SDK Events (Real-Time, Automatic)

The component internally handles typing indicators and message sending. No manual SDK listener attachment needed.

Custom View Slots

headerView

Custom view above the composer input.

footerView

Custom view below the composer input.

sendButtonView

Replace the send button.

auxillaryButtonView

Replace the sticker and AI button area.

attachmentOptions

Override the default attachment options.

Multiple Attachments

The composer supports sending several attachments in one go. Tapping a media or file option opens a multi-select picker; the picks are staged in an attachment tray above the input box, upload immediately, and are sent together when the user taps send. How it works:
  • Multi-select picking — the photo/video picker and the document picker both allow selecting multiple items, capped to the app’s per-message limit.
  • Attachment tray — each staged file shows as a tile (thumbnail for media, chip for files/audio) with a live upload progress ring, a ✕ to cancel or remove, and tap-to-retry on network failure.
  • Upload before send — files upload as soon as they are staged; the send button stays disabled until every upload finishes. Text typed in the composer becomes the caption of the batch.
  • One message per attachment type — a mixed pick is split into separate messages in a fixed order (images → videos → audios → files) that render as grouped bubbles in the message list.
  • Clipboard paste — images, videos, documents and audio files copied to the clipboard can be pasted straight into the composer and stage into the tray.
  • Voice notes stay standalone — a mic recording always sends immediately as its own message and is never staged.
  • Attachments cannot be added while editing a message; the attachment button is disabled for the duration of the edit.

Limits and Validation

Limits are governed by the app’s server settings (CometChat dashboard) — the composer reads them at runtime and they cannot be overridden client-side: Tapping an error tile shows a snack bar with the reason (“File exceeds N MB.”, “This file type isn’t allowed.”). The snack bar’s appearance is themable through CometChatErrorStateStyle:

Disabling Multiple Attachments

Set enableMultipleAttachments to false to restore the legacy behavior — single-item pickers that send immediately with no tray:
This is composer-side only: received multi-attachment messages still render with the grouped bubbles (see Message List).

Common Patterns

Thread composer

Minimal composer — text only

Pre-filled text

Disable typing indicators

Disable mentions

Custom send button action


Styling

Style Hierarchy

  1. Global styles (CometChatMessageComposer.style) apply to all instances
  2. Instance styles override global for specific instances

Global Level Styling

Instance Level Styling

Key Style Properties

Sub-Component Styles

Customization Matrix


Props

All props are optional. Sorted alphabetically.

Methods

set(textFormatter:)

Sets a custom text formatter for the composer input.

setDisableMentionAll(_:)

Disables or enables the @all mention feature that notifies all group members.

setMentionAllLabel(::)

Customizes the label displayed for @all mentions in the suggestions list.