Skip to main content

Where It Fits

CometChatMessageComposer is a Component that enables users to write and send a variety of messages, including text, image, video, and custom messages. Features such as Live Reaction, Attachments, and Message Editing are also supported. Wire it alongside CometChatMessageHeader and CometChatMessageList to build a standard chat view.

Minimal Render


Actions and Events

Callback Props

onSendButtonPress

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

onError

Fires on internal errors (network failure, auth issue, SDK exception).

onTextChange

Fires as the user types in the composer input.

Global UI Events

CometChatUIEventHandler emits events subscribable from anywhere in the application. Add listeners and remove them on cleanup. When to use: sync external UI with message state changes. For example, update a notification badge when messages are sent, or trigger analytics when a message is edited.
In React 18 StrictMode, useEffect runs twice on mount in development. The component handles listener cleanup internally, but any additional listeners added alongside the component need cleanup in the useEffect return function to avoid duplicate event handling.

Custom View Slots

Each slot replaces a section of the default UI. Slots that accept parameters receive the relevant data for customization.

textFormatters

Custom text formatters for the composer input. To configure the existing Mentions look and feel check out CometChatMentionsFormatter.

attachmentOptions

Override the default attachment options with custom actions.

addAttachmentOptions

Extends the default attachment options with additional actions.

AuxiliaryButtonView

Replace the sticker button area with a custom view.
The MessageComposer Component utilizes the AuxiliaryButton to provide sticker functionality. Overriding the AuxiliaryButton will replace the sticker functionality.

SendButtonView

Replace the send button with a custom view.

HeaderView

Custom view above the composer input.

Styling

Using Style you can customize the look and feel of the component in your app. These parameters typically control elements such as the color, size, shape, and fonts used within the component.

Visibility Props


Next Steps

Message List

Display the list of messages in a conversation

Message Header

Display user or group details in the chat toolbar

Messages

Complete messaging interface with header, list, and composer

Component Styling

Customize the appearance of UI Kit components