Skip to main content
CometChatMessageHeader renders the header of a chat conversation showing user/group avatar, name, online/offline status, typing indicators, back navigation, and action buttons (call buttons, menu).

Where It Fits

CometChatMessageHeader is a toolbar component. It sits at the top of a chat screen above CometChatMessageList and CometChatMessageComposer. It automatically shows typing indicators and user presence in real-time.

Quick Start

For group chats, pass a Group object instead:
Prerequisites: CometChat SDK initialized with CometChatUIKit.init(), a user logged in, and a valid User or Group object.

Actions and Events

Callback Methods

onBack

Fires when the user presses the back button.

onError

SDK Events (Real-Time, Automatic)

The component listens to these SDK events internally. No manual setup needed.

Functionality


Overflow Menu

Available since v6.1.1 The header’s ⋯ button opens a menu built from the props you set, in this order: Search (when onSearchTap is set), Pinned Messages (see below), and User Info / Group Info (when onInfoTap is set). The button only renders when at least one entry applies, and never in thread mode — when parentMessage is set. onHeaderTap is separate: it fires when the avatar, name or subtitle is tapped.

Pinned messages

The Pinned Messages entry opens the conversation’s Pinned Messages screen. It renders when pinnedMessagesVisibility is not false and CometChat.isPinMessageEnabled() returns true. By default the kit pushes the screen itself, passing it the header’s user or group, onPinnedMessageItemTap as its onItemTap, and pinnedMessagesStyle as its style. Set onPinnedMessagesTap to take over presentation — a desktop layout that shows the list in a side panel rather than a pushed route, say, or to pass the screen’s other options such as hideUnpinOption.

Thread subscription

Passing the thread’s root message as parentMessage puts the header in thread mode and renders a notification bell in its trailing area, reflecting the live subscription state. Tapping it subscribes or unsubscribes the user. The bell is gated on UIKitSettings.enableThreadSubscription, which is false by default, and can be hidden with threadSubscriptionVisibility: false — see the Thread Subscription guide.

Custom View Slots

Subtitle View

Replace the default subtitle (online status / typing indicator / member count).

Leading View

Replace the avatar / left section.

Title View

Replace the name / title text.

Trailing View

Replace the right section (call buttons, menu, etc.).

Common Patterns

Header with info button for groups

Hide back button (embedded in tab layout)


Advanced

BLoC Access

Available since v6.2.0. Pass your own MessageHeaderBloc through messageHeaderBloc to own the header’s state. The header uses it instead of creating one, still sets the user or group on it, and does not close it on dispose — close it yourself.
On v6.1.1 and earlier, CometChatMessageHeader has no messageHeaderBloc parameter and always manages its own bloc — customize presentation with the view slots above instead. The header passes usersStatusVisibility to the bloc only when it creates the bloc itself; give your own bloc the same value through the MessageHeaderBloc constructor.

Public BLoC Methods


Style

Style Properties

See Component Styling for the full reference.

Next Steps

Message List

Display messages in a conversation

Message Composer

Compose and send messages

Call Buttons

Add voice and video call buttons

Component Styling

Detailed styling reference