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.| SDK Listener | Internal behavior |
|---|---|
onUserOnline / onUserOffline | Updates online/offline status indicator |
onTypingStarted / onTypingEnded | Shows/hides typing indicator in subtitle |
onGroupMemberJoined / onGroupMemberLeft / onGroupMemberKicked / onGroupMemberBanned | Updates group member count |
Functionality
| Method (Kotlin XML) | Compose Parameter | Description |
|---|---|---|
setUser(user) | user = user | Display a user’s header details |
setGroup(group) | group = group | Display a group’s header details |
setBackButtonVisibility(View.VISIBLE) | hideBackButton = false | Toggle back button |
setOnBackPress { } | onBackPress = { } | Back button callback |
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).
- 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