CometChatMessageHeader is a header bar component that sits at the top of a chat screen, displaying the avatar, name, and status of the user or group in the conversation.

Where It Fits
CometChatMessageHeader sits at the top of a chat screen. Wire it alongside CometChatMessageList and CometChatMessageComposer to build a complete messaging layout.
- Kotlin (XML Views)
- Jetpack Compose
activity_chat.xml
Quick Start
- Kotlin (XML Views)
- Jetpack Compose
Add to your layout XML:Set a
User or Group on the component — this is required for it to display data:CometChatUIKit.init(), a user logged in, and the UI Kit dependency added.
Actions and Events
Callback Methods
onBackPress
Fires when the user presses the back button in the header.
- Kotlin (XML Views)
- Jetpack Compose
onError
Fires on internal errors (network failure, auth issue, SDK exception).
- Kotlin (XML Views)
- Jetpack Compose
SDK Events (Real-Time, Automatic)
The component listens to these SDK events internally. No manual setup needed.Functionality
Custom View Slots
Leading View
Replace the avatar / left section.
- Kotlin (XML Views)
- Jetpack Compose
Subtitle View
Replace the subtitle text below the user’s or group’s name.
- Kotlin (XML Views)
- Jetpack Compose
Trailing View
Replace the right section (action buttons).Choosing between the trailing and auxiliary slots. These two slots have different semantics by design, in both Kotlin XML Views and Jetpack Compose. The auxiliary slot supplies custom content for the auxiliary section — the area that by default renders the voice/video call buttons — so providing it replaces those defaults, which is the intended way to take over that area entirely. The trailing slot is separate and has no default content, so it is purely additive. For extra header icons, use the trailing slot — the call buttons stay. Use the auxiliary slot when you deliberately want your own content in place of the call-button area.
- Kotlin (XML Views):
setTrailingView(...)(additive) vssetAuxiliaryViewListener(...)(replaces the auxiliary container, whose default child isCometChatCallButtons) - Jetpack Compose:
trailingView = { ... }(additive) vsauxiliaryView = { ... }(renders instead of the default call-button area)

- Kotlin (XML Views)
- Jetpack Compose
Item View
Replace the entire default header with a fully customized layout.
- Kotlin (XML Views)
- Jetpack Compose
Style
- Kotlin (XML Views)
- Jetpack Compose
Define a custom style in
themes.xml:themes.xml

ViewModel
- Kotlin (XML Views)
- Jetpack Compose
Next Steps
Message List
Display messages in a conversation
Message Composer
Rich input for sending messages
Component Styling
Detailed styling reference
ViewModel & Data
Custom ViewModels and repositories