Skip to main content
{
  "component": "CometChatMessageList",
  "package": "@cometchat/chat-uikit-react",
  "import": "import { CometChatMessageList } from \"@cometchat/chat-uikit-react\";",
  "cssImport": "import \"@cometchat/chat-uikit-react/css-variables.css\";",
  "description": "Scrollable list of sent and received messages with text, media, reactions, read receipts, threaded replies, and AI features.",
  "cssRootClass": ".cometchat-message-list",
  "primaryOutput": {
    "prop": "onThreadRepliesClick",
    "type": "(message: CometChat.BaseMessage) => void"
  },
  "props": {
    "data": {
      "user": { "type": "CometChat.User", "default": "undefined" },
      "group": { "type": "CometChat.Group", "default": "undefined" },
      "messagesRequestBuilder": { "type": "CometChat.MessagesRequestBuilder", "default": "SDK default" },
      "reactionsRequestBuilder": { "type": "CometChat.ReactionsRequestBuilder", "default": "undefined" },
      "parentMessageId": { "type": "number", "default": "undefined" },
      "templates": { "type": "CometChatMessageTemplate[]", "default": "SDK defaults" },
      "goToMessageId": { "type": "string", "default": "undefined" }
    },
    "callbacks": {
      "onThreadRepliesClick": "(message: CometChat.BaseMessage) => void",
      "onReactionClick": "(reaction: CometChat.ReactionCount, message: CometChat.BaseMessage) => void",
      "onReactionListItemClick": "(reaction: CometChat.Reaction, message: CometChat.BaseMessage) => void",
      "onError": "((error: CometChat.CometChatException) => void) | null"
    },
    "visibility": {
      "hideDateSeparator": { "type": "boolean", "default": false },
      "hideStickyDate": { "type": "boolean", "default": false },
      "hideReceipts": { "type": "boolean", "default": false },
      "hideError": { "type": "boolean", "default": false },
      "hideReplyInThreadOption": { "type": "boolean", "default": false },
      "hideReplyOption": { "type": "boolean", "default": false },
      "hideTranslateMessageOption": { "type": "boolean", "default": false },
      "hideEditMessageOption": { "type": "boolean", "default": false },
      "hideDeleteMessageOption": { "type": "boolean", "default": false },
      "hideReactionOption": { "type": "boolean", "default": false },
      "hideMessagePrivatelyOption": { "type": "boolean", "default": false },
      "hideCopyMessageOption": { "type": "boolean", "default": false },
      "hideMessageInfoOption": { "type": "boolean", "default": false },
      "hideAvatar": { "type": "boolean", "default": false },
      "hideGroupActionMessages": { "type": "boolean", "default": false },
      "hideModerationView": { "type": "boolean", "default": false },
      "hideFlagMessageOption": { "type": "boolean", "default": false },
      "hideFlagRemarkField": { "type": "boolean", "default": false },
      "showConversationStarters": { "type": "boolean", "default": false },
      "showSmartReplies": { "type": "boolean", "default": false },
      "showMarkAsUnreadOption": { "type": "boolean", "default": false },
      "showScrollbar": { "type": "boolean", "default": false }
    },
    "behavior": {
      "messageAlignment": { "type": "MessageListAlignment", "default": "MessageListAlignment.standard" },
      "scrollToBottomOnNewMessages": { "type": "boolean", "default": false },
      "quickOptionsCount": { "type": "number", "default": 3 },
      "startFromUnreadMessages": { "type": "boolean", "default": false },
      "isAgentChat": { "type": "boolean", "default": false },
      "loadLastAgentConversation": { "type": "boolean", "default": false }
    },
    "sound": {
      "disableSoundForMessages": { "type": "boolean", "default": true },
      "customSoundForMessages": { "type": "string", "default": "undefined" }
    },
    "ai": {
      "smartRepliesKeywords": { "type": "string[]", "default": "[\"what\",\"when\",\"why\",\"who\",\"where\",\"how\",\"?\"]" },
      "smartRepliesDelayDuration": { "type": "number", "default": 10000 }
    },
    "dateFormatting": {
      "separatorDateTimeFormat": "CalendarObject",
      "stickyDateTimeFormat": "CalendarObject",
      "messageSentAtDateTimeFormat": "CalendarObject",
      "messageInfoDateTimeFormat": "CalendarObject"
    },
    "viewSlots": {
      "headerView": "JSX.Element",
      "footerView": "JSX.Element",
      "loadingView": "JSX.Element",
      "emptyView": "JSX.Element",
      "errorView": "JSX.Element"
    },
    "formatting": {
      "textFormatters": { "type": "CometChatTextFormatter[]", "default": "default formatters" }
    }
  },
  "events": [
    { "name": "CometChatMessageEvents.ccMessageEdited", "payload": "IMessages" },
    { "name": "CometChatMessageEvents.ccMessageDeleted", "payload": "CometChat.BaseMessage" },
    { "name": "CometChatMessageEvents.ccMessageRead", "payload": "CometChat.BaseMessage" },
    { "name": "CometChatMessageEvents.ccReplyToMessage", "payload": "IMessages" },
    { "name": "CometChatUIEvents.ccOpenChat", "payload": "IOpenChat" },
    { "name": "CometChatUIEvents.ccActiveChatChanged", "payload": "IActiveChatChanged" }
  ],
  "sdkListeners": [
    "onTextMessageReceived", "onMediaMessageReceived", "onCustomMessageReceived",
    "onMessageEdited", "onMessageDeleted", "onMessageModerated",
    "onTypingStarted", "onTypingEnded",
    "onMessagesDelivered", "onMessagesRead", "onMessagesDeliveredToAll", "onMessagesReadByAll"
  ],
  "types": {
    "MessageListAlignment": { "left": 0, "standard": 1 },
    "CalendarObject": { "today": "string", "yesterday": "string", "lastWeek": "string", "otherDays": "string" }
  }
}

Where It Fits

CometChatMessageList renders a scrollable, real-time message feed for a user or group conversation. Wire it alongside CometChatMessageHeader and CometChatMessageComposer to build a standard chat view.
import { useState, useEffect } from "react";
import { CometChat } from "@cometchat/chat-sdk-javascript";
import {
  CometChatMessageHeader,
  CometChatMessageList,
  CometChatMessageComposer,
} from "@cometchat/chat-uikit-react";
import "@cometchat/chat-uikit-react/css-variables.css";

function ChatView() {
  const [chatUser, setChatUser] = useState<CometChat.User>();

  useEffect(() => {
    CometChat.getUser("uid").then((user) => setChatUser(user));
  }, []);

  return chatUser ? (
    <div style={{ height: "100vh", display: "flex", flexDirection: "column" }}>
      <CometChatMessageHeader user={chatUser} />
      <CometChatMessageList user={chatUser} />
      <CometChatMessageComposer user={chatUser} />
    </div>
  ) : null;
}

Minimal Render

import { useState, useEffect } from "react";
import { CometChat } from "@cometchat/chat-sdk-javascript";
import { CometChatMessageList } from "@cometchat/chat-uikit-react";
import "@cometchat/chat-uikit-react/css-variables.css";

function MessageListDemo() {
  const [chatUser, setChatUser] = useState<CometChat.User>();

  useEffect(() => {
    CometChat.getUser("uid").then((user) => setChatUser(user));
  }, []);

  return chatUser ? <CometChatMessageList user={chatUser} /> : null;
}

export default MessageListDemo;
Root CSS class: .cometchat-message-list

Filtering Messages

Pass a CometChat.MessagesRequestBuilder to messagesRequestBuilder. The UID/GUID parameters are always overridden internally based on the user/group prop.
import { CometChat } from "@cometchat/chat-sdk-javascript";
import { CometChatMessageList } from "@cometchat/chat-uikit-react";

function FilteredMessageList() {
  return (
    <CometChatMessageList
      user={chatUser}
      messagesRequestBuilder={
        new CometChat.MessagesRequestBuilder().setLimit(5)
      }
    />
  );
}

Reactions Request Builder

import { CometChat } from "@cometchat/chat-sdk-javascript";
import { CometChatMessageList } from "@cometchat/chat-uikit-react";

function ReactionsFilteredList() {
  return (
    <CometChatMessageList
      user={chatUser}
      reactionsRequestBuilder={
        new CometChat.ReactionsRequestBuilder().setLimit(5)
      }
    />
  );
}
Refer to MessagesRequestBuilder for the full builder API.

Actions and Events

Callback Props

onThreadRepliesClick

Fires when a threaded message reply count is clicked.
import { CometChatMessageList } from "@cometchat/chat-uikit-react";
import { CometChat } from "@cometchat/chat-sdk-javascript";

function MessageListWithThreads() {
  return (
    <CometChatMessageList
      user={chatUser}
      onThreadRepliesClick={(message: CometChat.BaseMessage) => {
        console.log("Thread:", message.getId());
      }}
    />
  );
}

onReactionClick

Fires when a reaction on a message bubble is clicked.
import { CometChatMessageList } from "@cometchat/chat-uikit-react";
import { CometChat } from "@cometchat/chat-sdk-javascript";

function MessageListWithReactions() {
  return (
    <CometChatMessageList
      user={chatUser}
      onReactionClick={(reaction: CometChat.ReactionCount, message: CometChat.BaseMessage) => {
        console.log("Reaction:", reaction, "on message:", message.getId());
      }}
    />
  );
}

onReactionListItemClick

Fires when a specific reaction in the reaction detail view is clicked.
import { CometChatMessageList } from "@cometchat/chat-uikit-react";
import { CometChat } from "@cometchat/chat-sdk-javascript";

function MessageListWithReactionDetail() {
  return (
    <CometChatMessageList
      user={chatUser}
      onReactionListItemClick={(reaction: CometChat.Reaction, message: CometChat.BaseMessage) => {
        console.log("Reaction detail:", reaction, message.getId());
      }}
    />
  );
}

onError

Fires on internal errors.
import { CometChatMessageList } from "@cometchat/chat-uikit-react";
import { CometChat } from "@cometchat/chat-sdk-javascript";

function MessageListWithError() {
  return (
    <CometChatMessageList
      user={chatUser}
      onError={(error: CometChat.CometChatException) => {
        console.error("MessageList error:", error);
      }}
    />
  );
}

Global UI Events

EventFires whenPayload
CometChatMessageEvents.ccMessageEditedA message is editedIMessages
CometChatMessageEvents.ccMessageDeletedA message is deletedCometChat.BaseMessage
CometChatMessageEvents.ccMessageReadA message is readCometChat.BaseMessage
CometChatMessageEvents.ccReplyToMessageUser replies to a messageIMessages
CometChatUIEvents.ccOpenChatUser opens a chatIOpenChat
CometChatUIEvents.ccActiveChatChangedActive chat changesIActiveChatChanged
import { useEffect } from "react";
import { CometChatMessageEvents, CometChatUIEvents } from "@cometchat/chat-uikit-react";

function useMessageListEvents() {
  useEffect(() => {
    const editedSub = CometChatMessageEvents.ccMessageEdited.subscribe(
      (data) => console.log("Edited:", data)
    );
    const deletedSub = CometChatMessageEvents.ccMessageDeleted.subscribe(
      (msg) => console.log("Deleted:", msg)
    );

    return () => {
      editedSub?.unsubscribe();
      deletedSub?.unsubscribe();
    };
  }, []);
}

SDK Events (Real-Time, Automatic)

The component listens to these SDK events internally:
SDK ListenerInternal behavior
onTextMessageReceived / onMediaMessageReceived / onCustomMessageReceivedAppends new message to list
onMessageEdited / onMessageDeletedUpdates/removes message in list
onTypingStarted / onTypingEndedShows/hides typing indicator
onMessagesDelivered / onMessagesRead / onMessagesDeliveredToAll / onMessagesReadByAllUpdates receipt ticks
onMessageModeratedUpdates moderated message state

Custom View Slots

SlotTypeReplaces
headerViewJSX.ElementArea above the message list
footerViewJSX.ElementArea below the message list
loadingViewJSX.ElementLoading state
emptyViewJSX.ElementEmpty state
errorViewJSX.ElementError state
templatesCometChatMessageTemplate[]Message bubble rendering
textFormattersCometChatTextFormatter[]Text formatting in messages

headerView

Custom view above the message list.
import { useState, useEffect } from "react";
import { CometChat } from "@cometchat/chat-sdk-javascript";
import { CometChatMessageList, CometChatButton } from "@cometchat/chat-uikit-react";

function MessageListWithHeader() {
  const [chatUser, setChatUser] = useState<CometChat.User>();

  useEffect(() => {
    CometChat.getUser("uid").then((user) => setChatUser(user));
  }, []);

  return chatUser ? (
    <CometChatMessageList
      user={chatUser}
      headerView={
        <div className="header-view">
          <CometChatButton text="Notes" />
          <CometChatButton text="Pinned Message" />
          <CometChatButton text="Saved Links" />
        </div>
      }
    />
  ) : null;
}

footerView

Custom view below the message list.
import { CometChatMessageList, CometChatButton } from "@cometchat/chat-uikit-react";

function MessageListWithFooter() {
  return (
    <CometChatMessageList
      user={chatUser}
      footerView={
        <div className="footer-view">
          <CometChatButton text="Ice Breakers" />
          <CometChatButton text="+1-212-456-7890" />
        </div>
      }
    />
  );
}

templates

Custom message bubble templates via CometChatMessageTemplate.
import { useState, useEffect } from "react";
import { CometChat } from "@cometchat/chat-sdk-javascript";
import {
  CometChatMessageList,
  ChatConfigurator,
  CometChatActionsIcon,
} from "@cometchat/chat-uikit-react";

function MessageListCustomTemplates() {
  const [chatUser, setChatUser] = useState<CometChat.User>();

  useEffect(() => {
    CometChat.getUser("uid").then((user) => setChatUser(user));
  }, []);

  const getTemplates = () => {
    const templates = ChatConfigurator.getDataSource().getAllMessageTemplates();
    templates.map((data) => {
      data.options = (loggedInUser, message, group) => {
        const defaults = ChatConfigurator.getDataSource().getMessageOptions(
          loggedInUser, message, group
        );
        defaults.push(
          new CometChatActionsIcon({
            id: "custom",
            title: "Custom Action",
            onClick: () => console.log("custom action"),
          })
        );
        return defaults;
      };
    });
    return templates;
  };

  return chatUser ? (
    <CometChatMessageList user={chatUser} templates={getTemplates()} />
  ) : null;
}

Date Time Formatting

Customize timestamps using CalendarObject:
import { CometChatMessageList, CalendarObject } from "@cometchat/chat-uikit-react";

function MessageListCustomDates() {
  const dateFormat = new CalendarObject({
    today: "hh:mm A",
    yesterday: "[yesterday]",
    otherDays: "DD/MM/YYYY",
  });

  return (
    <CometChatMessageList
      user={chatUser}
      separatorDateTimeFormat={dateFormat}
      stickyDateTimeFormat={dateFormat}
      messageSentAtDateTimeFormat={dateFormat}
      messageInfoDateTimeFormat={dateFormat}
    />
  );
}

Common Patterns

Threaded message list

import { CometChatMessageList } from "@cometchat/chat-uikit-react";

function ThreadedMessageList() {
  return (
    <CometChatMessageList
      user={chatUser}
      parentMessageId={parentMessage.getId()}
    />
  );
}

Hide all chrome — minimal list

import { CometChatMessageList } from "@cometchat/chat-uikit-react";

function MinimalMessageList() {
  return (
    <CometChatMessageList
      user={chatUser}
      hideReceipts={true}
      hideAvatar={true}
      hideDateSeparator={true}
      hideStickyDate={true}
      hideGroupActionMessages={true}
    />
  );
}

Left-aligned messages

import { CometChatMessageList, MessageListAlignment } from "@cometchat/chat-uikit-react";

function LeftAlignedList() {
  return (
    <CometChatMessageList
      user={chatUser}
      messageAlignment={MessageListAlignment.left}
    />
  );
}

AI conversation starters and smart replies

import { CometChatMessageList } from "@cometchat/chat-uikit-react";

function AIMessageList() {
  return (
    <CometChatMessageList
      user={chatUser}
      showConversationStarters={true}
      showSmartReplies={true}
      smartRepliesKeywords={["what", "when", "why", "how", "?"]}
      smartRepliesDelayDuration={10000}
    />
  );
}

CSS Architecture

The component uses CSS custom properties (design tokens) defined in @cometchat/chat-uikit-react/css-variables.css. The cascade:
  1. Global tokens set on the .cometchat root wrapper.
  2. Component CSS (.cometchat-message-list) consumes these tokens via var().
  3. Overrides target .cometchat-message-list descendant selectors.

Key Selectors

TargetSelector
Root.cometchat-message-list
Error state.cometchat-message-list__error-state-view
Footer smart replies.cometchat-message-list__footer-smart-replies
Footer conversation starters.cometchat-message-list__footer-conversation-starter
Outgoing message bubble.cometchat-message-bubble-outgoing
Incoming message bubble.cometchat-message-bubble-incoming
Message bubble status info.cometchat-message-bubble__status-info-view
Thread view replies.cometchat-message-bubble__thread-view-replies
Text bubble.cometchat-message-bubble .cometchat-text-bubble
Date separator.cometchat-message-bubble__status-info-view .cometchat-date

Customization Matrix

What to changeWhereProperty/APIExample
Handle thread clicksComponent propsonThreadRepliesClickonThreadRepliesClick={(msg) => openThread(msg)}
Filter messagesComponent propsmessagesRequestBuildermessagesRequestBuilder={builder}
Toggle visibilityComponent propshide<Feature> boolean propshideReceipts={true}
Custom message bubblesComponent propstemplatestemplates={customTemplates}
Add header/footerComponent propsheaderView / footerViewheaderView={<div>...</div>}
Change colors, fonts, spacingGlobal CSSTarget .cometchat-message-list class.cometchat-message-bubble-outgoing { background: blue; }

Accessibility

Message bubbles are rendered as semantic elements. Date separators provide temporal context. The list supports keyboard scrolling. Thread reply counts are interactive and keyboard-focusable. Reaction buttons activate on Enter/Space. Avatar images include the sender name as alt text.

Props

All props are optional. Sorted alphabetically.

customSoundForMessages

URL to a custom audio file for incoming message notifications.
Typestring
Defaultundefined

disableSoundForMessages

Disables the notification sound for incoming messages.
Typeboolean
Defaulttrue

emptyView

Custom component displayed when there are no messages.
TypeJSX.Element
DefaultBuilt-in empty state

errorView

Custom component displayed when an error occurs.
TypeJSX.Element
DefaultBuilt-in error state

footerView

Custom component displayed below the message list.
TypeJSX.Element
Defaultundefined

goToMessageId

Scrolls to the specified message on initial load.
Typestring
Defaultundefined

group

The group for group conversation messages.
TypeCometChat.Group
Defaultundefined

headerView

Custom component displayed above the message list.
TypeJSX.Element
Defaultundefined

hideAvatar

Hides avatars on messages.
Typeboolean
Defaultfalse

hideCopyMessageOption

Hides the copy message option.
Typeboolean
Defaultfalse

hideDateSeparator

Hides date separators between message groups.
Typeboolean
Defaultfalse

hideDeleteMessageOption

Hides the delete message option.
Typeboolean
Defaultfalse

hideEditMessageOption

Hides the edit message option.
Typeboolean
Defaultfalse

hideError

Hides the default and custom error views.
Typeboolean
Defaultfalse

hideFlagMessageOption

Hides the “Report Message” option.
Typeboolean
Defaultfalse

hideFlagRemarkField

Hides the remark text area in the flag message dialog.
Typeboolean
Defaultfalse

hideGroupActionMessages

Hides group action messages (join, leave, kick, etc.).
Typeboolean
Defaultfalse

hideMessageInfoOption

Hides the message info option.
Typeboolean
Defaultfalse

hideMessagePrivatelyOption

Hides the “Message Privately” option.
Typeboolean
Defaultfalse

hideModerationView

Hides the moderation view below moderated messages.
Typeboolean
Defaultfalse

hideReactionOption

Hides the reaction option.
Typeboolean
Defaultfalse

hideReceipts

Hides read/delivery receipt indicators.
Typeboolean
Defaultfalse

hideReplyInThreadOption

Hides the “Reply in Thread” option.
Typeboolean
Defaultfalse

hideReplyOption

Hides the reply option.
Typeboolean
Defaultfalse

hideStickyDate

Hides the sticky date header.
Typeboolean
Defaultfalse

hideTranslateMessageOption

Hides the translate message option.
Typeboolean
Defaultfalse

isAgentChat

Toggles AI Agent functionality for the message list.
Typeboolean
Defaultfalse

loadingView

Custom component displayed during the loading state.
TypeJSX.Element
DefaultBuilt-in shimmer

loadLastAgentConversation

Loads the most recent existing agent conversation on mount.
Typeboolean
Defaultfalse

messageAlignment

Controls message alignment.
TypeMessageListAlignment
DefaultMessageListAlignment.standard
enum MessageListAlignment {
  left,     // 0
  standard, // 1
}

messageInfoDateTimeFormat

Format for message info timestamps.
TypeCalendarObject
DefaultComponent default

messageSentAtDateTimeFormat

Format for message sent-at timestamps.
TypeCalendarObject
DefaultComponent default

messagesRequestBuilder

Controls which messages load and in what order.
TypeCometChat.MessagesRequestBuilder
DefaultSDK default
UID/GUID are always overridden internally.

onError

Callback fired when the component encounters an error.
Type((error: CometChat.CometChatException) => void) | null
Defaultundefined

onReactionClick

Callback fired when a reaction on a message is clicked.
Type(reaction: CometChat.ReactionCount, message: CometChat.BaseMessage) => void
Defaultundefined

onReactionListItemClick

Callback fired when a reaction list item is clicked.
Type(reaction: CometChat.Reaction, message: CometChat.BaseMessage) => void
Defaultundefined

onThreadRepliesClick

Callback fired when a threaded message reply count is clicked.
Type(message: CometChat.BaseMessage) => void
Defaultundefined

parentMessageId

Displays threaded conversation for the specified parent message.
Typenumber
Defaultundefined

quickOptionsCount

Number of message options visible in the main menu before overflow.
Typenumber
Default3

reactionsRequestBuilder

Controls how reactions are fetched for messages.
TypeCometChat.ReactionsRequestBuilder
Defaultundefined

scrollToBottomOnNewMessages

Auto-scrolls to bottom when new messages arrive.
Typeboolean
Defaultfalse

separatorDateTimeFormat

Format for date separator timestamps.
TypeCalendarObject
DefaultComponent default

showConversationStarters

Shows AI conversation starters.
Typeboolean
Defaultfalse

showMarkAsUnreadOption

Shows “Mark Unread” option in message actions.
Typeboolean
Defaultfalse

showScrollbar

Shows the scrollbar in the message list.
Typeboolean
Defaultfalse

showSmartReplies

Shows AI smart replies.
Typeboolean
Defaultfalse

smartRepliesDelayDuration

Delay in milliseconds before smart replies appear.
Typenumber
Default10000

smartRepliesKeywords

Keywords that trigger smart replies.
Typestring[]
Default["what", "when", "why", "who", "where", "how", "?"]

startFromUnreadMessages

Loads from the first unread message if available.
Typeboolean
Defaultfalse

stickyDateTimeFormat

Format for sticky date header timestamps.
TypeCalendarObject
DefaultComponent default

templates

Custom message bubble templates.
TypeCometChatMessageTemplate[]
DefaultSDK defaults
See CometChatMessageTemplate.

textFormatters

Custom text formatters for message content.
TypeCometChatTextFormatter[]
DefaultDefault formatters from data source
See CometChatMentionsFormatter.

user

The user for 1-on-1 conversation messages.
TypeCometChat.User
Defaultundefined

Events

EventPayloadFires when
CometChatMessageEvents.ccMessageEditedIMessagesMessage edited
CometChatMessageEvents.ccMessageDeletedCometChat.BaseMessageMessage deleted
CometChatMessageEvents.ccMessageReadCometChat.BaseMessageMessage read
CometChatMessageEvents.ccReplyToMessageIMessagesUser replies to message
CometChatUIEvents.ccOpenChatIOpenChatChat opened
CometChatUIEvents.ccActiveChatChangedIActiveChatChangedActive chat changes

CSS Selectors

TargetSelector
Root.cometchat-message-list
Error state.cometchat-message-list__error-state-view
Footer smart replies.cometchat-message-list__footer-smart-replies
Footer conversation starters.cometchat-message-list__footer-conversation-starter
Outgoing bubble.cometchat-message-bubble-outgoing
Incoming bubble.cometchat-message-bubble-incoming
Status info view.cometchat-message-bubble__status-info-view
Thread view replies.cometchat-message-bubble__thread-view-replies
Text bubble.cometchat-message-bubble .cometchat-text-bubble
Delete bubble.cometchat-message-bubble .cometchat-delete-bubble