Skip to main content
{
  "component": "CometChatCompactMessageComposer",
  "package": "cometchat_chat_uikit",
  "import": "import 'package:cometchat_chat_uikit/cometchat_chat_uikit.dart';",
  "description": "A compact, pill-shaped message composer that provides a streamlined messaging experience with inline rich text formatting toolbar, voice recording, attachments, mentions, and auxiliary actions. Designed for a modern, minimal aesthetic while maintaining full messaging functionality.",
  "primaryOutput": {
    "prop": "onSendButtonTap",
    "type": "Function(BuildContext, BaseMessage, PreviewMessageMode?)?"
  },
  "props": {
    "data": {
      "user": {
        "type": "User?",
        "default": "null",
        "note": "User object for the message composer (one of user or group is required)"
      },
      "group": {
        "type": "Group?",
        "default": "null",
        "note": "Group object for the message composer (one of user or group is required)"
      },
      "text": {
        "type": "String?",
        "default": "null",
        "note": "Initial text for the input field"
      },
      "parentMessageId": {
        "type": "int",
        "default": "0",
        "note": "ID of the parent message for threaded replies"
      }
    },
    "callbacks": {
      "onChange": "Function(String)?",
      "onSendButtonTap": "Function(BuildContext, BaseMessage, PreviewMessageMode?)?",
      "onError": "OnError?",
      "onToolbarVisibilityChange": "void Function(bool isVisible)?",
      "onMentionLimitReached": "void Function(int limit)?",
      "onEditCancel": "void Function()?"
    },
    "visibility": {
      "hideVoiceRecordingButton": { "type": "bool", "default": false },
      "hideSendButton": { "type": "bool", "default": false },
      "hideAttachmentButton": { "type": "bool", "default": false },
      "hideStickersButton": { "type": "bool", "default": false },
      "disableMentions": { "type": "bool", "default": false },
      "disableTypingEvents": { "type": "bool", "default": false }
    },
    "richText": {
      "enableRichTextFormatting": { "type": "bool", "default": true },
      "showRichTextFormattingOptions": { "type": "bool", "default": true },
      "showTextSelectionMenuItems": { "type": "bool", "default": true },
      "hideRichTextFormattingOptions": { "type": "Set<FormatType>?", "default": null }
    },
    "sound": {
      "disableSoundForMessages": { "type": "bool", "default": false },
      "customSoundForMessage": { "type": "String?", "default": null }
    },
    "viewSlots": {
      "auxiliaryButtonView": "ComposerWidgetBuilder?",
      "headerView": "ComposerWidgetBuilder?",
      "footerView": "ComposerWidgetBuilder?"
    },
    "formatting": {
      "placeholderText": { "type": "String?", "default": null },
      "maxLine": { "type": "int", "default": 4 },
      "enterKeyBehavior": { "type": "EnterKeyBehavior", "default": "EnterKeyBehavior.newLine" }
    }
  },
  "events": [],
  "sdkListeners": [],
  "compositionExample": {
    "description": "CometChatCompactMessageComposer is typically used at the bottom of a messaging screen, paired with CometChatMessageHeader and CometChatMessageList",
    "components": ["CometChatMessageHeader", "CometChatMessageList", "CometChatMessages"],
    "flow": "User types message → Composer sends message → MessageList updates"
  },
  "types": {
    "CometChatCompactMessageComposerStyle": {
      "backgroundColor": "Color?",
      "border": "BoxBorder?",
      "borderRadius": "BorderRadiusGeometry?",
      "composeBoxBackgroundColor": "Color?",
      "composeBoxBorderRadius": "BorderRadiusGeometry?",
      "composeBoxBorder": "BoxBorder?",
      "sendButtonIconColor": "Color?",
      "sendButtonBackgroundColor": "Color?",
      "textStyle": "TextStyle?",
      "placeholderTextStyle": "TextStyle?"
    }
  }
}

Where It Fits

CometChatCompactMessageComposer is a Widget that provides a streamlined, modern messaging input experience. It features a pill-shaped compose box with an inline rich text formatting toolbar, voice recording, attachments, mentions, and auxiliary actions like stickers. Compared to CometChatMessageComposer, the compact variant offers:
  • A rounded, pill-shaped input field
  • An inline rich text formatting toolbar displayed below the input
  • Configurable Enter key behavior (send message or new line)
  • Text selection context menu with formatting options
  • Inline audio recorder that replaces the compose box during recording
import 'package:cometchat_chat_uikit/cometchat_chat_uikit.dart';

// CometChatCompactMessageComposer is typically used at the bottom of a messaging screen
class MessagingScreen extends StatelessWidget {
  final User user;

  const MessagingScreen({required this.user});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: [
          CometChatMessageHeader(user: user),
          Expanded(child: CometChatMessageList(user: user)),
          CometChatCompactMessageComposer(user: user),
        ],
      ),
    );
  }
}

Minimal Render

The simplest way to render CometChatCompactMessageComposer:
import 'package:cometchat_chat_uikit/cometchat_chat_uikit.dart';

// For a user conversation
CometChatCompactMessageComposer(
  user: user,
)

// For a group conversation
CometChatCompactMessageComposer(
  group: group,
)

Actions and Events

Callback Props

Component-level callbacks that fire on specific user interactions:
CallbackSignatureFires When
onSendButtonTapFunction(BuildContext, BaseMessage, PreviewMessageMode?)?User taps the send button
onChangeFunction(String)?Text in the input field changes
onErrorOnError?An error occurs
onToolbarVisibilityChangevoid Function(bool isVisible)?Rich text toolbar visibility changes
onMentionLimitReachedvoid Function(int limit)?Mention limit is exceeded
onEditCancelvoid Function()?Edit mode is cancelled
stateCallBackFunction(CometChatCompactMessageComposerController)?Controller state callback for accessing controller functions
CometChatCompactMessageComposer(
  user: user,
  onSendButtonTap: (BuildContext context, BaseMessage baseMessage, PreviewMessageMode? previewMessageMode) {
    // Handle send button tap
  },
  onChange: (String text) {
    // Handle text change
  },
  onError: (e) {
    // Handle error
  },
  onToolbarVisibilityChange: (bool isVisible) {
    // Handle toolbar visibility change
  },
  onMentionLimitReached: (int limit) {
    // Handle mention limit reached
  },
  onEditCancel: () {
    // Handle edit cancel
  },
)

Rich Text Formatting

CometChatCompactMessageComposer includes built-in rich text formatting support with an inline toolbar displayed below the input field.

Configuration

PropTypeDefaultDescription
enableRichTextFormattingbooltrueMaster switch for rich text formatting. When false, toolbar and text selection menu items are disabled
showRichTextFormattingOptionsbooltrueControls whether the rich text toolbar is visible above the composer. Only works when enableRichTextFormatting is true
showTextSelectionMenuItemsbooltrueControls whether formatting options appear in the text selection context menu. Only works when enableRichTextFormatting is true
hideRichTextFormattingOptionsSet<FormatType>?nullSpecifies which format types to hide from the rich text toolbar
richTextToolbarStyleCometChatRichTextToolbarStyle?-Custom styling for the rich text toolbar
// Enable rich text with all options
CometChatCompactMessageComposer(
  user: user,
  enableRichTextFormatting: true,
  showRichTextFormattingOptions: true,
  showTextSelectionMenuItems: true,
)

// Hide specific formatting options from the toolbar
CometChatCompactMessageComposer(
  user: user,
  hideRichTextFormattingOptions: {
    FormatType.strikethrough,
    FormatType.codeBlock,
  },
)

// Disable rich text formatting entirely
CometChatCompactMessageComposer(
  user: user,
  enableRichTextFormatting: false,
)

Enter Key Behavior

Configure what happens when the Enter key is pressed using the enterKeyBehavior prop.
ValueBehavior
EnterKeyBehavior.newLineInserts a new line (default)
EnterKeyBehavior.sendMessageSends the message immediately
// Send message on Enter
CometChatCompactMessageComposer(
  user: user,
  enterKeyBehavior: EnterKeyBehavior.sendMessage,
)

// New line on Enter (default)
CometChatCompactMessageComposer(
  user: user,
  enterKeyBehavior: EnterKeyBehavior.newLine,
)

Custom View Slots

Customize the appearance of CometChatCompactMessageComposer by replacing default views with your own widgets.
SlotSignatureReplaces
auxiliaryButtonViewComposerWidgetBuilder?Auxiliary button area (stickers, emoji)
headerViewComposerWidgetBuilder?Header section above the composer
footerViewComposerWidgetBuilder?Footer section below the composer
attachmentOptionsComposerActionsBuilder?Attachment options list

Example: Custom Auxiliary Button View

CometChatCompactMessageComposer(
  user: user,
  auxiliaryButtonView: (context, user, group, id) {
    final existingAuxiliaryOptions = CometChatUIKit.getDataSource()
        .getAuxiliaryOptions(user, group, context, id, Color(0xFFA1A1A1));
    return Row(
      children: [
        existingAuxiliaryOptions,
        Icon(
          Icons.location_pin,
          color: Color(0xFF6852D6),
        ),
      ],
    );
  },
)

Example: Custom Header View

CometChatCompactMessageComposer(
  user: user,
  headerView: (context, user, group, id) {
    return Container(
      margin: EdgeInsets.only(bottom: 2, left: 8, right: 8),
      padding: EdgeInsets.all(8),
      decoration: BoxDecoration(
        color: Color(0xFFEDEAFA),
        borderRadius: BorderRadius.circular(8),
      ),
      child: Row(
        children: [
          Icon(Icons.volume_off, size: 20, color: Color(0xFF6852D6)),
          Text(
            "User has paused their notifications",
            style: TextStyle(fontSize: 14, fontWeight: FontWeight.w400),
          ),
        ],
      ),
    );
  },
)
CometChatCompactMessageComposer(
  user: user,
  footerView: (context, user, group, id) {
    return Container(
      width: MediaQuery.of(context).size.width / 1.08,
      color: Colors.yellow,
      padding: const EdgeInsets.all(8),
      child: const Center(child: Text("Your Footer Widget")),
    );
  },
)

Example: Custom Attachment Options

CometChatCompactMessageComposer(
  user: user,
  attachmentOptions: (context, user, group, id) {
    return <CometChatMessageComposerAction>[
      CometChatMessageComposerAction(
        id: "Custom Option 1",
        title: "Custom Option 1",
        icon: Icon(Icons.play_circle, color: Colors.black),
      ),
      CometChatMessageComposerAction(
        id: "Custom Option 2",
        title: "Custom Option 2",
        icon: Icon(Icons.add_box, color: Colors.black),
      ),
    ];
  },
)

Styling

Customize the appearance of CometChatCompactMessageComposer using CometChatCompactMessageComposerStyle.

Style Properties

PropertyTypeDescription
backgroundColorColor?Background color of the outer composer container
borderBoxBorder?Border of the outer composer container
borderRadiusBorderRadiusGeometry?Border radius of the outer composer container
composeBoxBackgroundColorColor?Background color of the pill-shaped compose box
composeBoxBorderRadiusBorderRadiusGeometry?Border radius of the compose box
composeBoxBorderBoxBorder?Border of the compose box
textStyleTextStyle?Style of the input text
textColorColor?Color of the input text
placeholderTextStyleTextStyle?Style of the placeholder text
placeholderTextColorColor?Color of the placeholder text
sendButtonIconColorColor?Color of the send button icon when enabled
sendButtonBackgroundColorColor?Background color of the send button when enabled
sendButtonDisabledIconColorColor?Color of the send button icon when disabled
sendButtonDisabledBackgroundColorColor?Background color of the send button when disabled
sendButtonBorderRadiusBorderRadiusGeometry?Border radius of the send button
attachmentButtonIconColorColor?Color of the attachment button icon
attachmentButtonBackgroundColorColor?Background color of the attachment button
attachmentButtonBorderRadiusBorderRadiusGeometry?Border radius of the attachment button
voiceRecordingButtonIconColorColor?Color of the voice recording button icon
voiceRecordingButtonBackgroundColorColor?Background color of the voice recording button
voiceRecordingButtonBorderRadiusBorderRadiusGeometry?Border radius of the voice recording button
richTextToggleIconColorColor?Color of the rich text toggle icon when inactive
richTextToggleActiveIconColorColor?Color of the rich text toggle icon when active
richTextToggleBackgroundColorColor?Background color of the rich text toggle when inactive
richTextToggleActiveBackgroundColorColor?Background color of the rich text toggle when active
richTextToggleBorderRadiusBorderRadiusGeometry?Border radius of the rich text toggle button
auxiliaryButtonIconColorColor?Color of auxiliary button icons
auxiliaryButtonBackgroundColorColor?Background color of auxiliary buttons
auxiliaryButtonBorderRadiusBorderRadiusGeometry?Border radius of auxiliary buttons
dividerColorColor?Color of dividers
dividerHeightdouble?Height of dividers
closeIconTintColor?Color of the close icon in the preview banner

Nested Styles

PropertyTypeDescription
richTextToolbarStyleCometChatRichTextToolbarStyle?Style for the rich text formatting toolbar
richTextFormatterStyleCometChatRichTextFormatterStyle?Style for rich text formatting in the input field
messagePreviewStyleCometChatMessagePreviewStyle?Style for the message preview (edit/reply banner)
mentionsStyleCometChatMentionsStyle?Style for mentions
suggestionListStyleCometChatSuggestionListStyle?Style for the suggestion list
mediaRecorderStyleCometChatMediaRecorderStyle?Style for the media recorder
attachmentOptionSheetStyleCometChatAttachmentOptionSheetStyle?Style for the attachment option sheet

Example: Custom Styling

CometChatCompactMessageComposer(
  user: user,
  compactMessageComposerStyle: CometChatCompactMessageComposerStyle(
    sendButtonBackgroundColor: Color(0xFFF76808),
    attachmentButtonIconColor: Color(0xFFF76808),
    auxiliaryButtonIconColor: Color(0xFFF76808),
  ),
)

Example: Custom Compose Box Styling

CometChatCompactMessageComposer(
  user: user,
  compactMessageComposerStyle: CometChatCompactMessageComposerStyle(
    composeBoxBackgroundColor: Color(0xFFF5F5F5),
    composeBoxBorderRadius: BorderRadius.circular(24),
    composeBoxBorder: Border.all(color: Color(0xFF6852D6), width: 1.5),
    textColor: Color(0xFF333333),
    placeholderTextColor: Color(0xFF999999),
  ),
)

Example: Custom Rich Text Toolbar Style

CometChatCompactMessageComposer(
  user: user,
  compactMessageComposerStyle: CometChatCompactMessageComposerStyle(
    richTextToolbarStyle: CometChatRichTextToolbarStyle(
      backgroundColor: Color(0xFFE4EBF5),
      iconColor: Color(0xFF6852D6),
      activeIconColor: Colors.white,
      activeIconBackgroundColor: Color(0xFF6852D6),
    ),
  ),
)

Example: Custom Media Recorder Style

CometChatCompactMessageComposer(
  user: user,
  compactMessageComposerStyle: CometChatCompactMessageComposerStyle(
    mediaRecorderStyle: CometChatMediaRecorderStyle(
      recordIndicatorBackgroundColor: Color(0xFFF44649),
      recordIndicatorBorderRadius: BorderRadius.circular(20),
      pauseButtonBorderRadius: BorderRadius.circular(8),
      deleteButtonBorderRadius: BorderRadius.circular(8),
      stopButtonBorderRadius: BorderRadius.circular(8),
    ),
  ),
)

Advanced

Text Formatters

Assigns the list of text formatters. To configure the existing Mentions look and feel check out CometChatMentionsFormatter.
CometChatCompactMessageComposer(
  user: user,
  textFormatters: [
    CometChatMentionsFormatter(
      style: CometChatMentionsStyle(
        mentionSelfTextBackgroundColor: Color(0xFFF76808),
        mentionTextBackgroundColor: Colors.white,
        mentionTextColor: Colors.black,
        mentionSelfTextColor: Colors.white,
      ),
    ),
  ],
)

Mention Configuration

PropTypeDefaultDescription
disableMentionsboolfalseDisables the mention suggestion list
disableMentionAllboolfalseDisables the @all option in mention suggestions
mentionAllLabelString?-Custom label for @all mention
mentionAllLabelIdString?-Custom label ID for @all mention
CometChatCompactMessageComposer(
  user: user,
  disableMentions: false,
  disableMentionAll: true,
  mentionAllLabel: "Everyone",
)

Custom Icons

PropTypeDescription
attachmentIconWidget?Custom icon for the attachment button
voiceRecordingIconWidget?Custom icon for the voice recording button
sendButtonIconWidget?Custom icon for the send button
recorderStartButtonIconWidget?Custom icon for the recorder start/play button
recorderPauseButtonIconWidget?Custom icon for the recorder pause button
recorderDeleteButtonIconWidget?Custom icon for the recorder delete button
recorderStopButtonIconWidget?Custom icon for the recorder stop button
recorderSendButtonIconWidget?Custom icon for the recorder send button
CometChatCompactMessageComposer(
  user: user,
  attachmentIcon: Icon(Icons.add_circle, color: Color(0xFF6852D6)),
  sendButtonIcon: Icon(Icons.send, color: Colors.white, size: 20),
  voiceRecordingIcon: Icon(Icons.mic, color: Color(0xFF6852D6)),
)

Props Reference

PropTypeDefaultDescription
userUser?nullUser object for the message composer
groupGroup?nullGroup object for the message composer
compactMessageComposerStyleCometChatCompactMessageComposerStyle?-Sets style for the compact message composer
enableRichTextFormattingbooltrueMaster switch for rich text formatting
showRichTextFormattingOptionsbooltrueControls rich text toolbar visibility
showTextSelectionMenuItemsbooltrueControls formatting options in text selection menu
hideRichTextFormattingOptionsSet<FormatType>?nullFormat types to hide from the toolbar
richTextToolbarStyleCometChatRichTextToolbarStyle?-Custom styling for the rich text toolbar
placeholderTextString?-Hint text for the input field
maxLineint4Maximum number of lines the input can expand to
textString?-Initial text for the input field
textEditingControllerTextEditingController?-Controls the state of the text field
enterKeyBehaviorEnterKeyBehaviorEnterKeyBehavior.newLineDefines Enter key behavior (send or new line)
hideAttachmentButtonboolfalseHides the attachment button
hideVoiceRecordingButtonboolfalseHides the voice recording button
hideSendButtonboolfalseHides the send button
hideImageAttachmentOptionboolfalseHides the image attachment option
hideVideoAttachmentOptionboolfalseHides the video attachment option
hideAudioAttachmentOptionboolfalseHides the audio attachment option
hideFileAttachmentOptionboolfalseHides the file attachment option
hidePollsOptionboolfalseHides the polls option
hideCollaborativeDocumentOptionboolfalseHides the collaborative document option
hideCollaborativeWhiteboardOptionboolfalseHides the collaborative whiteboard option
hideTakePhotoOptionboolfalseHides the take photo option
hideStickersButtonboolfalseHides the stickers button
disableMentionsboolfalseDisables mentions in the composer
disableMentionAllboolfalseDisables @all mentions in groups
mentionAllLabelString?-Custom label for group mentions
mentionAllLabelIdString?-Custom label ID for group mentions
disableTypingEventsboolfalseDisables typing indicator events
disableSoundForMessagesboolfalseDisables sound for sent messages
customSoundForMessageString?-URL for custom sound
customSoundForMessagePackageString?-Package name for custom sound asset
parentMessageIdint0ID of the parent message for threads
onChangeFunction(String)?-Callback triggered when text changes
onSendButtonTapFunction(...)?-Callback when send button is tapped
onErrorOnError?-Callback to handle errors
onToolbarVisibilityChangevoid Function(bool)?-Callback when toolbar visibility changes
onMentionLimitReachedvoid Function(int)?-Callback when mention limit is exceeded
onEditCancelvoid Function()?-Callback when edit mode is cancelled
stateCallBackFunction(CometChatCompactMessageComposerController)?-Callback to access controller functions
auxiliaryButtonViewComposerWidgetBuilder?-Custom auxiliary button widget
headerViewComposerWidgetBuilder?-Custom header view
footerViewComposerWidgetBuilder?-Custom footer view
attachmentOptionsComposerActionsBuilder?-Custom attachment options
textFormattersList<CometChatTextFormatter>?-List of text formatters
attachmentIconWidget?-Custom attachment icon
voiceRecordingIconWidget?-Custom voice recording icon
sendButtonIconWidget?-Custom send button icon
recorderStartButtonIconWidget?-Custom recorder start button icon
recorderPauseButtonIconWidget?-Custom recorder pause button icon
recorderDeleteButtonIconWidget?-Custom recorder delete button icon
recorderStopButtonIconWidget?-Custom recorder stop button icon
recorderSendButtonIconWidget?-Custom recorder send button icon

Message Composer

The standard message composer component

Message Header

Display user or group details in the header

Message List

Display messages in a conversation

Mentions Formatter

Configure mentions look and feel