Overview
The CometChatMessageHeader component displays the header section of a chat conversation. It shows information about the user or group being chatted with, including real-time status updates, typing indicators, and provides action buttons for calls, search, and AI-powered conversation summary. The component follows a Hybrid Approach architecture where:- MessageHeaderService handles all SDK interactions, state management, and real-time updates using Angular Signals
- Component @Input properties allow developers to override service behavior for flexibility
- Both service methods and @Input properties are available, with @Input taking priority when provided
Key Features
- Real-time Updates: Automatic updates for user online/offline status and typing indicators
- Flexible Customization: Extensive template projection for all UI sections (header, leading, title, subtitle, trailing)
- Service-Based Architecture: Clean separation of concerns with Angular Signals for reactive state management
- Keyboard Navigation: Full keyboard accessibility with Tab, Enter, Space, and Escape key support (WCAG 2.1 Level AA compliant)
- Call Integration: Built-in voice and video call buttons with customizable visibility
- AI Smart Chat Features: Support for conversation summary generation with configurable message count
- Search Integration: Optional search functionality with event emission
- Error Handling: Comprehensive error handling with event propagation
Basic Usage
Simple Implementation with User
Simple Implementation with Group
With Call Buttons and Search
Live Preview — message header for a user conversation.
Open in Storybook ↗
Properties
Entity Configuration Properties
| Property | Type | Default | Description |
|---|---|---|---|
user | CometChat.User | undefined | The user to display in the header (for 1-on-1 conversations). Mutually exclusive with group. |
group | CometChat.Group | undefined | The group to display in the header (for group conversations). Mutually exclusive with user. |
Display Control Properties
| Property | Type | Default | Description |
|---|---|---|---|
hideUserStatus | boolean | false | Hide the user’s online/offline status indicator |
showBackButton | boolean | false | Show the back button |
hideVoiceCallButton | boolean | true | Hide the voice call button. Defaults to true (hidden). When calling is enabled via UIKitSettingsBuilder.setCallingEnabled(true), the resolved default becomes false (visible). Set to true explicitly to hide even when calling is enabled. |
hideVideoCallButton | boolean | true | Hide the video call button. Defaults to true (hidden). When calling is enabled via UIKitSettingsBuilder.setCallingEnabled(true), the resolved default becomes false (visible). Set to true explicitly to hide even when calling is enabled. |
showSearchOption | boolean | false | Show the search option in the header |
showConversationSummaryButton | boolean | false | Show the AI conversation summary button |
callSettingsBuilder | CallSettingsBuilder | undefined | Custom CallSettingsBuilder forwarded to the call buttons and ongoing call screen. Follows the three-tier priority: @Input > GlobalConfig > default. |
AI Configuration Properties
| Property | Type | Default | Description |
|---|---|---|---|
summaryGenerationMessageCount | number | 1000 | Number of messages to use for AI summary generation |
enableAutoSummaryGeneration | boolean | false | Automatically generate conversation summary on component initialization |
Date/Time Configuration Properties
| Property | Type | Default | Description |
|---|---|---|---|
lastActiveAtDateTimeFormat | CalendarObject | undefined | Custom date/time format for the last active timestamp |
Template Properties
| Property | Type | Default | Description |
|---|---|---|---|
headerView | TemplateRef<any> | undefined | Custom template for the entire header (replaces all default content) |
itemView | TemplateRef<{user?: CometChat.User; group?: CometChat.Group}> | undefined | Custom template for the item section (replaces avatar, title, subtitle) |
leadingView | TemplateRef<{user?: CometChat.User; group?: CometChat.Group}> | undefined | Custom template for the leading section (avatar area) |
titleView | TemplateRef<{user?: CometChat.User; group?: CometChat.Group}> | undefined | Custom template for the title section (name) |
subtitleView | TemplateRef<{user?: CometChat.User; group?: CometChat.Group}> | undefined | Custom template for the subtitle section (status/typing/member count) |
trailingView | TemplateRef<{user?: CometChat.User; group?: CometChat.Group}> | undefined | Custom template for the trailing section (action buttons) |
backButtonView | TemplateRef<any> | undefined | Custom template for the back button |
auxiliaryButtonView | TemplateRef<{user?: CometChat.User; group?: CometChat.Group}> | undefined | Custom template for auxiliary buttons in the trailing section |
Events
| Event | Payload Type | Description |
|---|---|---|
backClick | void | Emitted when the back button is clicked |
itemClick | CometChat.User | CometChat.Group | Emitted when the header item (avatar/name area) is clicked |
searchClick | void | Emitted when the search option is clicked |
conversationSummaryClick | { messageCount: number } | Emitted when the conversation summary button is clicked or auto-generation is triggered |
voiceCallClick | CometChat.User | CometChat.Group | Emitted when the voice call button is clicked |
videoCallClick | CometChat.User | CometChat.Group | Emitted when the video call button is clicked |
error | CometChat.CometChatException | Emitted when an error occurs in the component or service |
Usage Patterns
CometChatMessageHeader supports two usage patterns for receiving the active user or group context.- Using Service
- Using Props
When used alongside
cometchat-conversations, the message header automatically subscribes to ChatStateService. No explicit [user] or [group] input is needed — the component reacts to conversation selection changes.Advanced Usage
With AI Conversation Summary
Enable AI-powered conversation summary with custom message count:Auto-Generate Summary on Load
With Search and Summary (Overflow Menu)
When both search and summary options are enabled, they appear in an overflow menu:Custom Call Settings
Override the defaultCallSettingsBuilder used when calls are initiated from the message header:
Custom Last Active Date Format
Customization with Templates
Custom Subtitle View
Customize the status/typing indicator section:Custom Leading View with Badge
Custom Trailing View with Additional Actions
Custom Back Button
Live Preview — message header with a custom back button.
Open in Storybook ↗
Keyboard Accessibility
CometChatMessageHeader is fully keyboard accessible and meets WCAG 2.1 Level AA standards.Keyboard Shortcuts
| Key | Action | Context |
|---|---|---|
Tab | Navigate between interactive elements | Global |
Shift + Tab | Navigate backwards | Global |
Enter | Activate focused element (back button, item, call buttons) | When element is focused |
Space | Activate focused element | When element is focused |
Escape | Close overflow menu | When menu is open |
Accessibility Features
ARIA Attributes:role="banner"on the header containerrole="button"on the clickable item sectionrole="status"on status indicators and typing indicatorsaria-labelwith user/group name and status informationaria-live="polite"for typing indicator announcements- Proper
tabindexmanagement for keyboard navigation
- Announces user/group name and status when focused
- Announces typing indicator changes
- Announces status changes (online/offline) via live region
- Semantic HTML structure with proper heading hierarchy
- Visible focus indicators (2px border) meeting WCAG contrast requirements
- Logical tab order through interactive elements
- Focus trap within overflow menu when open
- ✅ 2.1.1 Keyboard (Level A) - All functionality available via keyboard
- ✅ 2.1.2 No Keyboard Trap (Level A) - Users can navigate away using keyboard
- ✅ 2.4.3 Focus Order (Level A) - Logical focus order
- ✅ 2.4.7 Focus Visible (Level AA) - Visible focus indicators
- ✅ 4.1.2 Name, Role, Value (Level A) - Proper ARIA attributes
- ✅ 4.1.3 Status Messages (Level AA) - Screen reader announcements
Styling with CSS Variables
The CometChatMessageHeader component uses CSS variables for comprehensive theming:Dark Theme Example
Custom Brand Colors
Real-Time Features
Automatic Updates
The component automatically updates in real-time for:- User Status: Online/offline status changes are reflected immediately
- Typing Indicators: Shows when the user is typing (for 1-on-1 conversations)
- Group Typing: Shows who is typing in group conversations with support for multiple users
- Member Count: Updates when members join or leave a group
- Last Active: Updates the last active timestamp for offline users
Typing Indicator Display
For user conversations:- Shows “Typing…” when the user is typing
- Single user: “John is typing…”
- Two users: “John and Jane are typing…”
- Multiple users: “John and 2 others are typing…”
Error Handling
The component provides comprehensive error handling through theonError event:
For troubleshooting tips, see the Troubleshooting Guide.