Skip to main content
{
  "component": "CometChatMessageBubble",
  "package": "@cometchat/chat-uikit-react",
  "import": "import { CometChatMessageBubble } from \"@cometchat/chat-uikit-react\";",
  "description": "Layout shell that wraps plugin-rendered bubble content with shared chrome — avatar, sender name, bubble background, timestamp, receipts, thread replies, reactions, and context menu.",
  "cssRootClass": ".cometchat-message-bubble",
  "props": {
    "data": {
      "message": { "type": "CometChat.BaseMessage", "required": true },
      "alignment": { "type": "'left' | 'right' | 'center'", "required": true },
      "contentView": { "type": "ReactNode", "required": true, "note": "Inner content from the plugin's renderBubble()." },
      "group": { "type": "CometChat.Group" },
      "options": { "type": "CometChatMessageOption[]" },
      "quickOptionsCount": { "type": "number", "default": 2 }
    },
    "visibility": {
      "hideAvatar": { "type": "boolean", "default": false },
      "forceShowAvatar": { "type": "boolean", "default": false },
      "hideSenderName": { "type": "boolean", "default": false },
      "hideTimestamp": { "type": "boolean", "default": false },
      "hideThreadView": { "type": "boolean", "default": false },
      "hideReceipts": { "type": "boolean", "note": "Reads from GlobalConfig if not set." },
      "showError": { "type": "boolean", "default": false },
      "disableInteraction": { "type": "boolean", "default": false }
    },
    "config": {
      "messageSentAtDateTimeFormat": { "type": "CometChatDateFormatConfig" },
      "isSelected": { "type": "boolean" },
      "ariaPosinset": { "type": "number" },
      "ariaSetsize": { "type": "number" },
      "className": { "type": "string" },
      "setRef": { "type": "Ref<HTMLDivElement>" },
      "includeBottomViewHeight": { "type": "boolean", "default": false },
      "toggleOptionsVisibility": { "type": "boolean" }
    },
    "viewSlots": {
      "leadingView": "((message) => ReactNode) | null",
      "headerView": "((message) => ReactNode) | null",
      "statusInfoView": "((message) => ReactNode) | null",
      "footerView": "((message) => ReactNode) | null",
      "threadView": "((message) => ReactNode) | null",
      "replyView": "ReactNode | null",
      "bottomView": "((message) => ReactNode) | null"
    },
    "callbacks": {
      "onAvatarClick": "(user: CometChat.User) => void",
      "onThreadRepliesClick": "(message: CometChat.BaseMessage) => void",
      "onOptionClick": "(option: CometChatMessageOption, message: CometChat.BaseMessage) => void",
      "onReactionChipClick": "(messageId: number, emoji: string) => void",
      "onReactorClick": "(reaction: CometChat.Reaction, message: CometChat.BaseMessage) => void"
    }
  }
}

Where It Fits

CometChatMessageBubble is the layout shell for every message in the message list. The plugin system’s renderBubble() produces the inner content (text, image, video, etc.), and the bubble wraps it with shared chrome.
Live Preview — interact with the message bubble component.Open in Storybook ↗
import {
  CometChatMessageBubble,
  CometChatTextBubble,
} from "@cometchat/chat-uikit-react";

function MessageItem({ message, alignment }) {
  return (
    <CometChatMessageBubble
      message={message}
      alignment={alignment}
      contentView={
        <CometChatTextBubble message={message} isSentByMe={alignment === "right"} />
      }
    />
  );
}
Message bubbles are self-extracting: each bubble takes the SDK message and derives its own content (text, attachments, caption, poll data, call info, action text), reading the logged-in user, theme, and locale from hooks. Pass just message to render a bubble standalone — no plugin or pre-extracted props required. CometChatTextBubble also accepts an optional text override so media bubbles can render captions through it.

Shared Chrome Elements

ElementWhen ShownSource
AvatarIncoming + group + !hideAvatarmessage.getSender().getAvatar()
Sender nameIncoming + group + !hideSenderNamemessage.getSender().getName()
Bubble backgroundAlwaysType-specific: primary for outgoing, neutral for incoming
Timestamp!hideTimestampmessage.getSentAt() via CometChatDate
ReceiptsOutgoing + !hideReceiptsmessage.getReadAt() / getDeliveredAt()
Edited indicatormessage.getEditedAt() truthy”(edited)” text
Thread repliesmessage.getReplyCount() > 0 + !hideThreadViewReply count button
Context menuoptions.length > 0 + !disableInteractionHover/click

GlobalConfig Integration

hideReceipts reads from GlobalConfigContext when the prop is not explicitly set:
<GlobalConfigProvider config={{ hideReceipts: true }}>
  {/* All bubbles hide receipts unless overridden */}
  <CometChatMessageBubble hideReceipts={false} ... />  {/* This one shows receipts */}
</GlobalConfigProvider>

Props

message

The SDK message object. Required.
TypeCometChat.BaseMessage

alignment

Bubble alignment: 'left' (incoming), 'right' (outgoing), 'center' (action).
Type'left' | 'right' | 'center'

contentView

The inner content from the plugin’s renderBubble(). Required.
TypeReactNode

group

Group context. Enables avatar and sender name display.
TypeCometChat.Group
Defaultundefined

hideAvatar / hideSenderName / hideTimestamp / hideThreadView

Per-bubble display controls. Not in GlobalConfig.
Typeboolean
Defaultfalse

hideReceipts

Hide receipt indicators. Reads from GlobalConfig if not set.
Typeboolean
Defaultundefined (falls back to GlobalConfig, then false)

showError

Show error receipt icon instead of normal receipts.
Typeboolean
Defaultfalse

disableInteraction

Disable hover options and keyboard interactions.
Typeboolean
Defaultfalse

options

Context menu options for this message (the hover/overflow actions).
TypeCometChatMessageOption[]
Defaultundefined

quickOptionsCount

Number of quick options shown directly; the rest move to the overflow menu.
Typenumber
Default2

forceShowAvatar

Force-show the avatar for incoming messages even in 1:1 chats (used by agent chat).
Typeboolean
Defaultfalse

messageSentAtDateTimeFormat

Override the date format for the sent-at timestamp shown beside the bubble.
TypeCometChatDateFormatConfig
Defaultundefined

View override props

Render-prop overrides for each region of the bubble. Semantics for all of them: omit (undefined) to use the built-in default, pass null to suppress the region, or pass a function/node to override it.
PropTypeOverrides
leadingView((message) => ReactNode) | nullLeading view (avatar area)
headerView((message) => ReactNode) | nullHeader view (sender name area)
statusInfoView((message) => ReactNode) | nullStatus info (timestamp + receipts)
footerView((message) => ReactNode) | nullFooter (reactions area)
threadView((message) => ReactNode) | nullThread reply view
replyViewReactNode | nullReply preview (quoted message) above content
bottomView((message) => ReactNode) | nullView below the bubble (e.g. moderation footer)

Callback props

PropSignatureFires when
onAvatarClick(user: CometChat.User) => voidThe avatar is clicked
onThreadRepliesClick(message: CometChat.BaseMessage) => voidThe thread view is clicked
onOptionClick(option: CometChatMessageOption, message: CometChat.BaseMessage) => voidA context menu option is clicked
onReactionChipClick(messageId: number, emoji: string) => voidA reaction chip is clicked (toggle add/remove)
onReactorClick(reaction: CometChat.Reaction, message: CometChat.BaseMessage) => voidA reactor in the reaction list is clicked

Accessibility & advanced props

PropTypeDefaultDescription
isSelectedbooleanfalseWhether this message is selected
ariaPosinsetnumberPosition in the message list (1-indexed)
ariaSetsizenumberTotal messages in the list
classNamestringAdditional CSS class on the root element
setRefRef<HTMLDivElement>Ref to the outermost wrapper div (role="article")
includeBottomViewHeightbooleanfalseUse fit-content height for the options toolbar (useful with a bottomView)
toggleOptionsVisibilitybooleanundefinedExplicitly control options toolbar visibility (true = always, false = never, undefined = hover-based)

CSS Selectors

TargetSelector
Wrapper.cometchat-message-bubble__wrapper
Outgoing wrapper.cometchat-message-bubble__wrapper--outgoing
Avatar area.cometchat-message-bubble__leading-view
Bubble container.cometchat-message-bubble
Incoming.cometchat-message-bubble-incoming
Outgoing.cometchat-message-bubble-outgoing
Action (center).cometchat-message-bubble-action
Sender name.cometchat-message-bubble__sender-name
Body.cometchat-message-bubble__body
Content.cometchat-message-bubble__body-content-view
Status info.cometchat-message-bubble__body-status-info-view
Receipts.cometchat-receipts
Thread button.cometchat-message-bubble__thread-button