Overview
MessageComposer is a Component that enables users to write and send a variety of messages, including text, image, video, and custom messages. Features such as Attachments, and Message Editing are also supported by it.
Usage
Integration
The following code snippet illustrates how you can directly incorporate the MessageComposer component into your app.Actions
Actions dictate how a component functions. They are divided into two types: Predefined and User-defined. You can override either type, allowing you to tailor the behavior of the component to fit your specific needs.1. OnSendButtonClick
TheOnSendButtonClick
event gets activated when the send message button is clicked. It has a predefined function of sending messages entered in the composer EditText
. However, you can overide this action with the following code snippet.
2. onError
This action doesn’t change the behavior of the component but rather listens for any errors that occur in the MessageList component.3. onTextChange
This event is triggered as the user starts typing in the Message Composer.Filters
MessageComposer component does not have any available filters.Events
Events are emitted by aComponent
. By using event you can extend existing functionality. Being global events, they can be applied in Multiple Locations and are capable of being Added or Removed.
The list of events emitted by the Messages component is as follows.
Event | Description |
---|---|
ccMessageEdited | Triggers whenever a loggedIn user edits any message from the list of messages .it will have three states such as: inProgress, success and error. |
ccMessageSent | Triggers whenever a loggedIn user sends any message, it will have three states such as: inProgress, success and error. |
CometChatMessageEvents
Listener’s
Removing
CometChatMessageEvents
Listener’s
Customization
To fit your app’s design requirements, you can customize the appearance of the MessageComposer component. We provide exposed methods that allow you to modify the experience and behavior according to your specific needs.Style
To modify the styling, you can customise the css of MessageComposer Component. Example
Functionality
These are a set of small functional customizations that allow you to fine-tune the overall experience of the component. With these, you can change text, set custom icons, and toggle the visibility of UI elements.Property | Description | Code |
---|---|---|
Initial Composer Text | The initial text pre-filled in the message input when the component mounts. | initialComposerText="Hello" |
Disable Typing Events | Disables the typing indicator for the current message composer. | disableTypingEvents={true} |
Disable Mentions | Disables the mentions functionality in the message composer. | disableMentions={true} |
Hide Image Attachment Option | Hides the image attachment option in the message composer. | hideImageAttachmentOption={true} |
Hide Video Attachment Option | Hides the video attachment option in the message composer. | hideVideoAttachmentOption={true} |
Hide Audio Attachment Option | Hides the audio attachment option in the message composer. | hideAudioAttachmentOption={true} |
Hide File Attachment Option | Hides the file attachment option in the message composer. | hideFileAttachmentOption={true} |
Hide Polls Option | Hides the polls option in the message composer. | hidePollsOption={true} |
Hide Collaborative Document | Hides the collaborative document option in the message composer. | hideCollaborativeDocumentOption={true} |
Hide Collaborative Whiteboard | Hides the collaborative whiteboard option in the message composer. | hideCollaborativeWhiteboardOption={true} |
Hide Attachment Button | Hides the attachment button in the message composer. | hideAttachmentButton={true} |
Hide Voice Recording Button | Hides the voice recording button in the message composer. | hideVoiceRecordingButton={true} |
Hide Emoji Keyboard Button | Hides the emoji keyboard button in the message composer. | hideEmojiKeyboardButton={true} |
Hide Stickers Button | Hides the stickers button in the message composer. | hideStickersButton={true} |
Hide Send Button | Hides the send button in the message composer. | hideSendButton={true} |
Show Scrollbar | Controls the visibility of the scrollbar in the composer. | showScrollbar={true} |
User | Specifies the recipient of the message (user object). | user={chatUser} |
Group | Specifies the group to send messages to. Used if the user prop is not provided. | group={chatGroup} |
Parent Message ID | Specifies the ID of the parent message for threading or replying to a specific message. | parentMessageId={12345} |
Enter Key Behavior | Determines the behavior of the Enter key (e.g., send message or add a new line). | enterKeyBehavior={EnterKeyBehavior.SendMessage} |
Disable Sound for Message | Disables sound for incoming messages. | disableSoundForMessage={true} |
Custom Sound for Message | Specifies a custom audio sound for incoming messages. | customSoundForMessage="sound.mp3" |
Advanced
For advanced-level customization, you can set custom views to the component. This lets you tailor each aspect of the component to fit your exact needs and application aesthetics. You can create and define your views, layouts, and UI elements and then incorporate those into the component.AttachmentOptions
By usingattachmentOptions
, you can set a list of custom MessageComposerActions
for the MessageComposer Component. This will override the existing list of MessageComposerActions
.
Shown below is the default chat interface.


AuxiliaryButtonView
You can insert a custom view into the MessageComposer component to add additional functionality using the following method. Please note that the MessageComposer Component utilizes the AuxiliaryButton to provide sticker and AI functionality. Overriding the AuxiliaryButton will subsequently replace the sticker functionality. Shown below is the default chat interface.

SendButtonView
You can set a custom view in place of the already existing send button view. Shown below is the default chat interface.

HeaderView
You can set custom headerView to the MessageComposer component using the following method. Shown below is the default chat interface.
