AI Agent Component Spec
AI Agent Component Spec
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
.cometchat-message-composer
Actions and Events
Callback Props
onSendButtonClick
Fires when the send button is clicked. Overrides the default send behavior.onTextChange
Fires as the user types in the composer input.onError
Fires on internal errors.Global UI Events
| Event | Fires when | Payload |
|---|---|---|
CometChatMessageEvents.ccMessageSent | A message is sent | IMessages |
CometChatMessageEvents.ccMessageEdited | A message is edited | IMessages |
CometChatMessageEvents.ccReplyToMessage | User replies to a message | IMessages |
SDK Events (Real-Time, Automatic)
The component internally handles typing indicators and message sending. No manual SDK listener attachment needed.Custom View Slots
| Slot | Type | Replaces |
|---|---|---|
attachmentOptions | CometChatMessageComposerAction[] | Default attachment options list |
auxiliaryButtonView | JSX.Element | Sticker and AI button area |
sendButtonView | JSX.Element | Send button |
headerView | JSX.Element | Area above the composer input |
attachmentOptions
Override the default attachment options.
auxiliaryButtonView
Replace the sticker and AI button area.
sendButtonView
Replace the send button.
- TypeScript
- CSS
headerView
Custom view above the composer input.
- TypeScript
- CSS
Common Patterns
Thread composer
Minimal composer — text only
Enter key adds new line
Pre-filled text
CSS Architecture
The component uses CSS custom properties (design tokens) defined in@cometchat/chat-uikit-react/css-variables.css. The cascade:
- Global tokens set on the
.cometchatroot wrapper. - Component CSS (
.cometchat-message-composer) consumes these tokens viavar(). - Overrides target
.cometchat-message-composerdescendant selectors.
Key Selectors
| Target | Selector |
|---|---|
| Root | .cometchat-message-composer |
| Send button | .cometchat-message-composer__send-button |
| Send button active | .cometchat-message-composer__send-button-active |
| Sticker button popover | .cometchat-message-composer__auxilary-button-view-sticker-button .cometchat-popover__content |
| Emoji keyboard popover | .cometchat-message-composer__emoji-keyboard-button .cometchat-popover__content |
| Attachment popover | .cometchat-message-composer__secondary-button-view-attachment-button .cometchat-popover__content |
| Voice recording popover | .cometchat-message-composer__voice-recording-button .cometchat-popover__content |
| Header area | .cometchat-message-composer__header |
Customization Matrix
| What to change | Where | Property/API | Example |
|---|---|---|---|
| Override send behavior | Component props | onSendButtonClick | onSendButtonClick={(msg) => customSend(msg)} |
| Track text input | Component props | onTextChange | onTextChange={(text) => track(text)} |
| Toggle visibility | Component props | hide<Feature> boolean props | hideAttachmentButton={true} |
| Custom attachments | Component props | attachmentOptions | attachmentOptions={[new CometChatMessageComposerAction(...)]} |
| Replace UI sections | Component props | View slot props | sendButtonView={<div>...</div>} |
| Change Enter key behavior | Component props | enterKeyBehavior | enterKeyBehavior={EnterKeyBehavior.NewLine} |
| Change colors, fonts, spacing | Global CSS | Target .cometchat-message-composer class | .cometchat-message-composer__send-button { background: blue; } |
Accessibility
The text input is auto-focused and supports standard keyboard shortcuts. The send button activates on Enter (configurable viaenterKeyBehavior). Attachment, emoji, sticker, and voice recording buttons are keyboard-focusable and activate on Enter/Space. The mention suggestions list is keyboard-navigable with arrow keys.
Props
All props are optional. Sorted alphabetically.attachmentOptions
Custom attachment options list.| Type | CometChatMessageComposerAction[] |
| Default | undefined |
auxiliaryButtonView
Custom JSX replacing the sticker and AI button area.| Type | JSX.Element |
| Default | Built-in sticker/AI buttons |
customSoundForMessage
URL to a custom audio file for outgoing message notifications.| Type | string |
| Default | undefined |
disableMentionAll
Controls whether group mentions like @all appear in suggestions.| Type | boolean |
| Default | false |
disableMentions
Disables the mentions functionality.| Type | boolean |
| Default | false |
disableSoundForMessage
Disables sound for outgoing messages.| Type | boolean |
| Default | false |
disableTypingEvents
Disables the typing indicator for this composer.| Type | boolean |
| Default | false |
enterKeyBehavior
Determines Enter key behavior.| Type | EnterKeyBehavior |
| Default | EnterKeyBehavior.SendMessage |
group
The recipient group for the composer.| Type | CometChat.Group |
| Default | undefined |
headerView
Custom component displayed above the composer input.| Type | JSX.Element |
| Default | undefined |
hideAttachmentButton
Hides the entire attachment button.| Type | boolean |
| Default | false |
hideAudioAttachmentOption
Hides the audio attachment option.| Type | boolean |
| Default | false |
hideCollaborativeDocumentOption
Hides the collaborative document option.| Type | boolean |
| Default | false |
hideCollaborativeWhiteboardOption
Hides the collaborative whiteboard option.| Type | boolean |
| Default | false |
hideEmojiKeyboardButton
Hides the emoji keyboard button.| Type | boolean |
| Default | false |
hideFileAttachmentOption
Hides the file attachment option.| Type | boolean |
| Default | false |
hideImageAttachmentOption
Hides the image attachment option.| Type | boolean |
| Default | false |
hidePollsOption
Hides the polls option.| Type | boolean |
| Default | false |
hideSendButton
Hides the send button.| Type | boolean |
| Default | false |
hideStickersButton
Hides the stickers button.| Type | boolean |
| Default | false |
hideVideoAttachmentOption
Hides the video attachment option.| Type | boolean |
| Default | false |
hideVoiceRecordingButton
Hides the voice recording button.| Type | boolean |
| Default | false |
initialComposerText
Pre-fills the text input when the component mounts.| Type | string |
| Default | "" |
mentionAllLabel
Custom alias label for group mentions.| Type | string |
| Default | "all" |
mentionsGroupMembersRequestBuilder
Custom builder to control how mentioned group members are fetched.| Type | CometChat.GroupMembersRequestBuilder |
| Default | undefined |
mentionsUsersRequestBuilder
Custom builder to control how mentioned users are fetched.| Type | CometChat.UsersRequestBuilder |
| Default | undefined |
onError
Callback fired when the component encounters an error.| Type | ((error: CometChat.CometChatException) => void) | null |
| Default | undefined |
onSendButtonClick
Callback fired when the send button is clicked. Overrides default send behavior.| Type | (message: CometChat.BaseMessage, previewMessageMode?: PreviewMessageMode) => void |
| Default | undefined |
onTextChange
Callback fired as the user types.| Type | (text: string) => void |
| Default | undefined |
parentMessageId
Targets a thread; messages sent as replies to this parent.| Type | number |
| Default | undefined |
placeholderText
Placeholder text displayed in the message input field when empty.| Type | string |
| Default | "" |
sendButtonView
Custom JSX replacing the send button.| Type | JSX.Element |
| Default | Built-in send button |
showScrollbar
Shows the scrollbar in the composer input.| Type | boolean |
| Default | false |
textFormatters
Custom text formatters for the composer input.| Type | CometChatTextFormatter[] |
| Default | Default formatters from data source |
user
The recipient user for the composer.| Type | CometChat.User |
| Default | undefined |
Events
| Event | Payload | Fires when |
|---|---|---|
CometChatMessageEvents.ccMessageSent | IMessages | Message sent |
CometChatMessageEvents.ccMessageEdited | IMessages | Message edited |
CometChatMessageEvents.ccReplyToMessage | IMessages | User replies to message |
CSS Selectors
| Target | Selector |
|---|---|
| Root | .cometchat-message-composer |
| Send button | .cometchat-message-composer__send-button |
| Send button active | .cometchat-message-composer__send-button-active |
| Sticker popover | .cometchat-message-composer__auxilary-button-view-sticker-button .cometchat-popover__content |
| Emoji keyboard popover | .cometchat-message-composer__emoji-keyboard-button .cometchat-popover__content |
| Attachment popover | .cometchat-message-composer__secondary-button-view-attachment-button .cometchat-popover__content |
| Voice recording popover | .cometchat-message-composer__voice-recording-button .cometchat-popover__content |
| Header area | .cometchat-message-composer__header |