Skip to main content
The CometChatMessageHeader component displays user or group details in the toolbar including avatar, name, status, and typing indicators. It also provides navigation controls and call buttons.
CometChatMessageHeader showing user avatar, name, online status, and call buttons in the navigation bar

Where It Fits

CometChatMessageHeader displays the recipient’s information at the top of the chat screen. It’s typically used within CometChatMessages alongside CometChatMessageList and CometChatMessageComposer.
CometChatMessageHeader showing user avatar, name, online status, and call buttons in the navigation bar

Minimal Render

CometChatMessageHeader showing minimal render with user details and default styling

Actions and Events

Callback Props

onBack

Fires when the back button is pressed. Use this for custom navigation handling.

onError

Fires when an error occurs.

Actions Reference

SDK Events (Real-Time, Automatic)


Custom View Slots

listItemView

Replace the entire header content with a custom view.
You can create a CustomHeaderView as a custom UIView:

leadingView

Customize the leading view (avatar area) of the header.
CometChatMessageHeader with custom leadingView showing avatar with Admin badge overlay
You can create a CustomLeadingView as a custom UIView:

titleView

Customize the title view of the header.
CometChatMessageHeader with custom titleView showing group name with Public badge
You can create a CustomTitleView as a custom UIView:

subtitleView

Customize the subtitle area (status, typing indicator).

trailView

Customize the right side of the header (call buttons, etc.).
CometChatMessageHeader with custom trailView showing video call, voice call, and bookmark buttons
You can create a CustomTrailView as a custom UIView:

Styling

Style Hierarchy

  1. Global styles (CometChatMessageHeader.style) apply to all instances
  2. Instance styles override global for specific instances

Global Level Styling

Instance Level Styling

CometChatMessageHeader with custom instance styling showing modified background color and text appearance

Key Style Properties

Customization Matrix


Connection Management

Manually control the WebSocket connection for the message header.

connect()

Establishes the WebSocket connection for real-time updates. Use this when you need to manually reconnect after disconnecting.

disconnect()

Disconnects the WebSocket connection. Use this when you want to temporarily stop receiving real-time updates, such as when the view is not visible.

set(options:)

Sets custom menu options for the message header. These options appear in the header’s menu (typically accessed via a more button or long press).

Props

All props are optional. Sorted alphabetically.

avatarStyle

Customizes the appearance of the avatar in the message header.

dateTimeFormatter

Custom formatter for date/time display in the message header (e.g., “Last seen at…”).

disableTyping

Disables typing indicators in the message header.

hideBackButton

Hides the back button in the header.

hideChatHistoryButton

Hides the AI chat history button in the header.

hideNewChatButton

Hides the AI new chat button in the header.

hideUserStatus

Hides the user status (online/offline/last active).

hideVideoCallButton

Hides the video call button.

hideVoiceCallButton

Hides the voice call button.

onAiChatHistoryClicked

Callback triggered when the AI chat history button is clicked.

onAiNewChatClicked

Callback triggered when the AI new chat button is clicked.

statusIndicatorStyle

Customizes the appearance of the online/offline status indicator.

typingIndicatorStyle

Customizes the appearance of the typing indicator in the message header subtitle.

Events

The MessageHeader component does not emit any global UI events.

Date Time Formatter

Customize how timestamps appear in the message header (e.g., “Last seen at…”) using the CometChatDateTimeFormatter.

Global Level Formatting

Instance Level Formatting

Available Formatters


Common Patterns

Hide call buttons

Custom back button action

Custom subtitle with typing indicator

Minimal header