CometChatThreadHeader component displays a header bar for threaded message views. It shows a truncated preview of the parent message, the reply count, and a close button to return to the main chat. Media parent messages display an appropriate icon (image, video, audio, file).
Overview
The Thread Header component provides:- Parent Message Preview: Truncated text preview of the parent message (max 50 characters)
- Media Icons: Displays type-specific icons for image, video, audio, and file messages
- Reply Count: Shows the number of replies with singular/plural localization
- Close Button: Returns the user to the main chat view
- Keyboard Navigation: Supports Tab, Enter, Space, and Escape key interactions
- Full ARIA Support: Includes
role="banner", descriptive labels, and accessible close button
Live Preview — default thread header preview.
Open in Storybook ↗
Basic Usage
Simple Thread Header
Usage Patterns
CometChatThreadHeader supports two usage patterns. The default service-based approach usesChatStateService to automatically receive the parent message context. Alternatively, you can
pass data explicitly via @Input() bindings.
- Using Service
- Using Props
When a thread is opened via the message list, See the ChatStateService API reference for the full list of signals, observables, and setter methods.
ChatStateService stores the active thread’s parent message. cometchat-thread-header automatically subscribes to this state — no explicit [parentMessage] binding required.Properties
| Property | Type | Default | Description |
|---|---|---|---|
parentMessage | CometChat.BaseMessage | required | The parent message of the thread. Used to display the message preview and media icon |
replyCount | number | 0 | The number of replies in the thread. Displayed with localized singular/plural text. When not provided, the count is automatically read from parentMessage.getReplyCount() |
Events
| Event | Payload Type | Description |
|---|---|---|
closeClick | void | Emitted when the close button is clicked, Enter/Space is pressed on the close button, or Escape is pressed while the header is focused |
backClick | void | Deprecated. Use closeClick instead. Emitted alongside closeClick for backward compatibility |
Customization
CSS Variables
The Thread Header component uses BEM-style CSS classes with CSS variable overrides:Responsive Behavior
The component adapts across breakpoints with dedicated CSS variables for tablet (max-width: 991px), mobile (max-width: 767px), and small mobile (max-width: 575px) — reducing padding, font sizes, and icon dimensions at smaller widths.
Accessibility
Keyboard Navigation
- Tab: Moves focus to the close button
- Enter / Space: Activates the close button when focused
- Escape: Closes the thread from anywhere within the header (via
@HostListener)
Screen Reader Support
- The header uses
role="banner"for landmark navigation - An
aria-labelcombines the parent message preview and reply count for context - The close button has a dedicated
aria-label(e.g., “Close thread”)
High Contrast & Reduced Motion
- Supports
prefers-contrast: highwith stronger borders and focus outlines - Supports
prefers-reduced-motion: reduceby disabling button transitions
Related Components
- CometChatMessageList - Displays messages within the thread
- CometChatMessageBubble - Renders individual messages in the thread