Skip to main content

Documentation Index

Fetch the complete documentation index at: https://cometchat-22654f5b-react-uikit-v7.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

{
  "component": "CometChatMessageHeader",
  "package": "@cometchat/chat-uikit-react",
  "import": "import { CometChatMessageHeader } from \"@cometchat/chat-uikit-react\";",
  "cssImport": "import \"@cometchat/chat-uikit-react/css-variables.css\";",
  "description": "Toolbar displaying conversation details with avatar, name, presence status, typing indicator, and call buttons.",
  "cssRootClass": ".cometchat-message-header",
  "primaryOutput": {
    "prop": "onItemClick",
    "type": "(entity: CometChat.User | CometChat.Group) => void"
  },
  "props": {
    "data": {
      "user": {
        "type": "CometChat.User",
        "default": "undefined",
        "note": "For 1-on-1 conversations. Mutually exclusive with group."
      },
      "group": {
        "type": "CometChat.Group",
        "default": "undefined",
        "note": "For group conversations. Mutually exclusive with user."
      },
      "callSettingsBuilder": {
        "type": "any",
        "default": "GlobalConfig.callSettingsBuilder or built-in default",
        "note": "Custom call settings builder for ongoing call sessions."
      },
      "lastActiveAtDateTimeFormat": {
        "type": "CometChatDateFormatConfig",
        "default": "relative time format"
      },
      "summaryGenerationMessageCount": {
        "type": "number",
        "default": 1000
      }
    },
    "callbacks": {
      "onBack": "() => void",
      "onItemClick": "(entity: CometChat.User | CometChat.Group) => void",
      "onSearchOptionClicked": "() => void",
      "onSummaryClick": "() => void",
      "onVoiceCallClick": "(entity: CometChat.User | CometChat.Group) => void",
      "onVideoCallClick": "(entity: CometChat.User | CometChat.Group) => void",
      "onError": "((error: CometChat.CometChatException) => void) | null"
    },
    "visibility": {
      "hideUserStatus": { "type": "boolean", "default": false },
      "hideBackButton": { "type": "boolean", "default": false },
      "showSearchOption": { "type": "boolean", "default": true },
      "showConversationSummaryButton": { "type": "boolean", "default": false },
      "enableAutoSummaryGeneration": { "type": "boolean", "default": false },
      "hideVoiceCallButton": { "type": "boolean", "default": false },
      "hideVideoCallButton": { "type": "boolean", "default": false }
    },
    "viewSlots": {
      "leadingView": "ReactNode",
      "titleView": "ReactNode",
      "subtitleView": "ReactNode",
      "trailingView": "ReactNode",
      "auxiliaryButtonView": "ReactNode"
    }
  },
  "eventsEmitted": [],
  "eventsReceived": [
    {
      "name": "ui:call/rejected",
      "payload": "{ call }",
      "description": "Re-enables call buttons after incoming call rejection"
    },
    {
      "name": "ui:call/ended",
      "payload": "{}",
      "description": "Resets all call state (re-enables buttons, hides call screens)"
    },
    {
      "name": "ui:call/join",
      "payload": "{ sessionId, isAudioOnly, group }",
      "description": "Starts a direct call (user clicked Join on meeting bubble)"
    },
    {
      "name": "ui:active-chat/changed",
      "payload": "{ unreadCount, ... }",
      "description": "Auto-triggers summary when unread >= 15 (if enabled)"
    },
    {
      "name": "ui:group/member-added",
      "payload": "{ group, members, messages }",
      "description": "Updates group member count"
    },
    {
      "name": "ui:group/member-kicked",
      "payload": "{ group, user, message }",
      "description": "Updates group member count"
    },
    {
      "name": "ui:group/member-banned",
      "payload": "{ group, user, message }",
      "description": "Updates group member count"
    },
    {
      "name": "ui:group/left",
      "payload": "{ group }",
      "description": "Updates group member count"
    },
    {
      "name": "ui:group/member-joined",
      "payload": "{ joinedGroup }",
      "description": "Updates group member count"
    },
    {
      "name": "ui:group/ownership-changed",
      "payload": "{ group }",
      "description": "Updates group member count"
    },
    {
      "name": "ui:group/member-scope-changed",
      "payload": "{ group, user, newScope }",
      "description": "Updates group member count"
    }
  ],
  "sdkListeners": [
    "onUserOnline",
    "onUserOffline",
    "onTypingStarted",
    "onTypingEnded",
    "onGroupMemberJoined",
    "onGroupMemberLeft",
    "onGroupMemberKicked",
    "onGroupMemberBanned",
    "onMemberAddedToGroup",
    "onIncomingCallReceived",
    "onOutgoingCallAccepted",
    "onOutgoingCallRejected",
    "onIncomingCallCancelled"
  ],
  "types": {
    "CometChatDateFormatConfig": {
      "today": "string | undefined",
      "yesterday": "string | undefined",
      "lastWeek": "string | undefined",
      "otherDays": "string | undefined",
      "relativeTime": {
        "minute": "string | undefined",
        "minutes": "string | undefined",
        "hour": "string | undefined",
        "hours": "string | undefined"
      }
    }
  }
}

Overview

CometChatMessageHeader is a toolbar component that sits at the top of the message panel. It displays the avatar, name, online status (for users), member count (for groups), typing indicator, and call buttons for the active conversation. Wire it with CometChatMessageList and CometChatMessageComposer to build a complete messaging experience.
Live Preview — interact with the default message header.Open in Storybook ↗
The component handles:
  • Displaying user avatar and name
  • Online/offline presence status (for 1-on-1 conversations)
  • Group member count (for group conversations)
  • Real-time typing indicators
  • Voice and video call buttons with call state management
  • Back navigation for mobile layouts
  • AI conversation summary trigger
  • Search option for in-conversation search
Note: user and group are mutually exclusive. Pass one or the other — not both. The component requires at least one to display anything.

Usage

Flat API (User Conversation)

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

function MessagePanel({ user }: { user: CometChat.User }) {
  return (
    <CometChatMessageHeader
      user={user}
      onItemClick={(entity) => openDetails(entity)}
      onBack={() => navigateBack()}
    />
  );
}

Flat API (Group Conversation)

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

function MessagePanel({ group }: { group: CometChat.Group }) {
  return (
    <CometChatMessageHeader
      group={group}
      onItemClick={(entity) => openDetails(entity)}
      hideVoiceCallButton={true}
    />
  );
}

Compound Composition

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

function CustomHeader({ user }: { user: CometChat.User }) {
  return (
    <CometChatMessageHeader.Root user={user} onBack={() => navigateBack()}>
      <CometChatMessageHeader.BackButton />
      <CometChatMessageHeader.Avatar />
      <CometChatMessageHeader.Title />
      <CometChatMessageHeader.Subtitle />
      <CometChatMessageHeader.CallButtons />
      <CometChatMessageHeader.SearchButton />
      <CometChatMessageHeader.AuxiliaryButtons />
    </CometChatMessageHeader.Root>
  );
}

Full Layout Example

import { useState } from "react";
import { CometChat } from "@cometchat/chat-sdk-javascript";
import {
  CometChatConversations,
  CometChatMessageHeader,
  CometChatMessageList,
  CometChatMessageComposer,
} from "@cometchat/chat-uikit-react";

function ChatApp() {
  const [user, setUser] = useState<CometChat.User | undefined>();
  const [group, setGroup] = useState<CometChat.Group | undefined>();

  const handleConversationClick = (conversation: CometChat.Conversation) => {
    const entity = conversation.getConversationWith();
    if (conversation.getConversationType() === "user") {
      setUser(entity as CometChat.User);
      setGroup(undefined);
    } else {
      setGroup(entity as CometChat.Group);
      setUser(undefined);
    }
  };

  return (
    <div style={{ display: "flex", height: "100vh" }}>
      <div style={{ width: 360 }}>
        <CometChatConversations onItemClick={handleConversationClick} />
      </div>
      <div style={{ flex: 1, display: "flex", flexDirection: "column" }}>
        <CometChatMessageHeader user={user} group={group} />
        <CometChatMessageList user={user} group={group} />
        <CometChatMessageComposer user={user} group={group} />
      </div>
    </div>
  );
}

Actions and Events

Callback Props

PropSignatureFires when
onBack() => voidUser clicks the back button
onItemClick(entity: CometChat.User | CometChat.Group) => voidUser clicks the avatar/name area
onSearchOptionClicked() => voidUser clicks the search button
onSummaryClick() => voidUser clicks the AI summary button
onVoiceCallClick(entity: CometChat.User | CometChat.Group) => voidUser clicks the voice call button
onVideoCallClick(entity: CometChat.User | CometChat.Group) => voidUser clicks the video call button
onError((error: CometChat.CometChatException) => void) | nullSDK error occurs

Events Emitted

This component does not emit any UI events directly. Call initiation publishes call events internally via the SDK.

Events Received

UI events this component subscribes to (published by other components):
EventPayloadBehavior
ui:call/rejected{ call }Re-enables call buttons after incoming call rejection
ui:call/ended{}Resets all call state (re-enables buttons, hides call screens)
ui:call/join{ sessionId, isAudioOnly, group }Starts a direct call (user clicked Join on meeting bubble)
ui:active-chat/changed{ unreadCount, ... }Auto-triggers summary when unread >= 15 (if enabled)
ui:group/member-added{ group, members, messages }Updates group member count
ui:group/member-kicked{ group, user, message }Updates group member count
ui:group/member-banned{ group, user, message }Updates group member count
ui:group/left{ group }Updates group member count
ui:group/member-joined{ joinedGroup }Updates group member count
ui:group/ownership-changed{ group }Updates group member count
ui:group/member-scope-changed{ group, user, newScope }Updates group member count

SDK Listeners (Automatic)

These SDK listeners are attached internally. The component updates its state automatically — no manual subscription needed:
  • Presence: onUserOnline, onUserOffline
  • Typing: onTypingStarted, onTypingEnded
  • Groups: onGroupMemberJoined, onGroupMemberLeft, onGroupMemberKicked, onGroupMemberBanned, onMemberAddedToGroup
  • Calls: onIncomingCallReceived, onOutgoingCallAccepted, onOutgoingCallRejected, onIncomingCallCancelled

Customization

View Props

Use view props to replace sections of the default UI while keeping the component’s behavior intact:
<CometChatMessageHeader
  user={user}
  leadingView={<MyCustomAvatar user={user} />}
  subtitleView={<MyCustomSubtitle />}
  trailingView={<MyCustomActions />}
/>
SlotTypeReplaces
leadingViewReactNodeAvatar area
titleViewReactNodeDisplay name
subtitleViewReactNodeStatus / typing indicator
trailingViewReactNodeCall buttons + overflow menu
auxiliaryButtonViewReactNodeAuxiliary button area

Compound Composition

For full layout control, use sub-components. Omit any sub-component to hide it:
<CometChatMessageHeader.Root user={user}>
  {/* No BackButton — it won't render */}
  <CometChatMessageHeader.Avatar />
  <CometChatMessageHeader.Title />
  <CometChatMessageHeader.Subtitle />
  {/* No CallButtons — they won't render */}
</CometChatMessageHeader.Root>
Available sub-components:
Sub-componentDescriptionPropsFlat API equivalent
RootContext provider and containerAll Root props + children
BackButtonBack navigation buttonclassName
AvatarUser/group avatarclassNameleadingView
TitleDisplay nameclassNametitleView
SubtitleStatus / typing indicatorclassNamesubtitleView
CallButtonsVoice and video call buttonsclassName
SearchButtonSearch triggeronClick, className
SummaryButtonAI summary triggeronClick, className
OverflowMenuAdditional actionsclassName
AuxiliaryButtonsCustom auxiliary buttonschildren, classNameauxiliaryButtonView

CSS Styling

Override design tokens on the component selector:
.cometchat-message-header {
  --cometchat-background-color-01: #1a1a2e;
  --cometchat-text-color-primary: #ffffff;
}

.cometchat-message-header__call-buttons {
  gap: 12px;
}

Props

All props are optional (but you need either user or group for the component to display anything).
View slot props (headerView, searchView, loadingView, emptyView, errorView, itemView, leadingView, titleView, subtitleView, trailingView) are convenience props available only on the flat API. In compound composition mode, use the corresponding sub-components directly.

user

The user to display in the header. Use for 1-on-1 conversations. Mutually exclusive with group.
TypeCometChat.User
Defaultundefined

group

The group to display in the header. Use for group conversations. Mutually exclusive with user.
TypeCometChat.Group
Defaultundefined

hideUserStatus

Hide the online/offline status indicator in the subtitle.
Typeboolean
Defaultfalse

hideBackButton

Hide the back navigation button. Useful on desktop layouts where back navigation is unnecessary.
Typeboolean
Defaultfalse

showSearchOption

Whether to show the search button in the header toolbar.
Typeboolean
Defaulttrue

showConversationSummaryButton

Whether to show the AI conversation summary button.
Typeboolean
Defaultfalse

enableAutoSummaryGeneration

Auto-trigger conversation summary when unread message count >= 15. Requires showConversationSummaryButton to be true and onSummaryClick to be provided.
Typeboolean
Defaultfalse

summaryGenerationMessageCount

Number of last messages to include in the summary request. Passed to the onSummaryClick callback via context.
Typenumber
Default1000

hideVoiceCallButton

Hide the voice call button.
Typeboolean
Defaultfalse

hideVideoCallButton

Hide the video call button.
Typeboolean
Defaultfalse

callSettingsBuilder

Custom call settings builder for ongoing call sessions. Passed to the OngoingCall component when a call is started. Falls back to GlobalConfig.callSettingsBuilder, then the built-in default.
Typeany
DefaultGlobalConfig.callSettingsBuilder or built-in default

lastActiveAtDateTimeFormat

Custom date/time format for the “last active” timestamp shown in the subtitle when the user is offline.
TypeCometChatDateFormatConfig
DefaultRelative time format

onBack

Callback when the back button is clicked.
Type() => void
Defaultundefined

onItemClick

Callback when the header item (avatar/name area) is clicked. Typically used to open a details panel.
Type(entity: CometChat.User | CometChat.Group) => void
Defaultundefined

onSearchOptionClicked

Callback when the search button is clicked.
Type() => void
Defaultundefined

onSummaryClick

Callback when the AI conversation summary button is clicked.
Type() => void
Defaultundefined

onVoiceCallClick

Callback when the voice call button is clicked. When provided, overrides the default call initiation behavior.
Type(entity: CometChat.User | CometChat.Group) => void
Defaultundefined (uses built-in call initiation)

onVideoCallClick

Callback when the video call button is clicked. When provided, overrides the default call initiation behavior.
Type(entity: CometChat.User | CometChat.Group) => void
Defaultundefined (uses built-in call initiation)

onError

Callback when an SDK error occurs during call operations or other internal processes.
Type((error: CometChat.CometChatException) => void) | null
Defaultnull

CSS Selectors

TargetSelector
Root container.cometchat-message-header
Back button.cometchat-message-header__back-button
Avatar.cometchat-message-header__avatar
Content area.cometchat-message-header__content
Title.cometchat-message-header__title
Subtitle.cometchat-message-header__subtitle
Trailing area.cometchat-message-header__trailing
Call buttons.cometchat-message-header__call-buttons
Search button.cometchat-message-header__search-button
Summary button.cometchat-message-header__summary-button

Next Steps

Message List

Display messages for the active conversation

Message Composer

Compose and send messages

Thread Header

Header for threaded message views

Theming

Customize colors, fonts, and spacing