Skip to main content
CometChatMessageComposer renders the message input area and sends messages to the active conversation. It supports text, media, mentions, voice notes, stickers, and AI-powered features.

Where It Fits

CometChatMessageComposer is an input component. Wire it with CometChatMessageHeader and CometChatMessageList to build a complete messaging layout.
activity_chat.xml

Quick Start

Add to your layout XML:
Set a User or Group:
Prerequisites: CometChat SDK initialized with CometChatUIKit.init(), a user logged in, and the UI Kit dependency added.
The MessageComposer manages runtime permissions. To ensure the ActivityResultLauncher is properly initialized, create the composer in the onCreate state of an activity. If using a fragment, load it in the activity’s onCreate.

Actions and Events

Callback Methods

onSendButtonClick

Fires when the send button is tapped. Override to intercept or replace the default message-sending logic.

onError

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

SDK Events

The MessageComposer does not attach SDK listeners directly. Typing indicators are managed internally when disableTypingEvents is false (default).

Functionality


Custom View Slots

Header View

Custom view above the text input area.

Send Button View

Replace the default send button.

Auxiliary Button View

Replace the auxiliary button area (stickers, AI).
If you override the auxiliary button with setAuxiliaryButtonView(), retrieve the default auxiliary buttons via CometChatUIKit.getDataSource().getAuxiliaryOption() and include them in your custom layout to preserve sticker/AI buttons.

Attachment Options

Replace the default attachment options.

Text Formatters (Mentions)


Style

Define a custom style in themes.xml:
themes.xml
See Component Styling for the full reference.

ViewModel

See ViewModel & Data for state observation and custom repositories.

Next Steps

Message List

Display messages in a conversation

Message Header

Display user/group info in the toolbar

Message Template

Customize message bubble structure

Component Styling

Detailed styling reference