Overview
The CometChatConversationItem component is a standalone Angular component designed to render a single conversation item. It is part of the enterprise refactoring that decomposes the monolithic CometChatConversations component into smaller, focused pieces. This component provides:- State Management: Support for active, selected, focused, and unread states
- Slot-Based Customization: Fine-grained control over individual UI elements
- Granular Events: Separate events for avatar, title, subtitle, timestamp, and badge clicks
- Backward Compatibility: Section templates for existing implementations
- Full Accessibility: ARIA labels, roles, and keyboard navigation support
Key Features
- Standalone Component: Can be used independently or within CometChatConversations
- 11 Customization Slots: Override specific UI elements without affecting others
- 8 Granular Events: Respond to precise user interactions
- Display Configuration: Hide receipts, user status, or group type icons
- Context Menu Support: Customizable actions for each conversation
- OnPush Change Detection: Optimized for performance
Basic Usage
Simple Implementation
Live Preview — interact with the component directly in the embed below.
Open in Storybook ↗
With State Management
Properties
Required Input Properties
State Input Properties
Live Preview — all states (default, active, selected, focused, unread) side by side.
Open in Storybook ↗
Display Configuration Properties
Customization Properties
Section Template Properties (Backward Compatibility)
Events
Slot-Based Customization
The component supports 11 slots via theConversationSlots interface, organized into three sections:
Slot Overview
Slot Context
All slot templates receive aConversationSlotContext object:
statusIndicator:{ status: string }- User status (‘online’, ‘offline’)groupTypeIcon:{ groupType: string }- Group type (‘public’, ‘private’, ‘password’)title:{ title: string }- Display namesubtitle:{ subtitle: string }- Last message previewtimestamp:{ timestamp: number }- Unix timestampunreadBadge:{ count: number }- Unread countreceipt:{ receiptStatus: string }- Receipt status
Custom Avatar Slot Example
Custom Unread Badge Slot Example
Custom Timestamp Slot Example
Event Handling
Granular Click Events
The component emits separate events for each clickable element, allowing precise handling:Selection Mode
Handle selection events for multi-select scenarios:Styling with CSS Variables
The CometChatConversationItem component uses CSS variables for comprehensive theming:Dark Theme Example
Custom Brand Colors
Accessibility
The CometChatConversationItem component includes comprehensive accessibility features:ARIA Attributes
role="listitem"on the conversation item containeraria-selectedindicates selection statearia-labelwith conversation name and unread countrole="status"on status indicators and badgesrole="img"on group type icons with appropriate labels
Keyboard Navigation
Screen Reader Support
The component announces:- Conversation name
- Unread message count (e.g., “5 unread messages”)
- Online/offline status for user conversations
- Group type for group conversations (private, password-protected)
Focus Management
- Clear focus indicators using CSS box-shadow
- Focus state is visually distinct from hover and active states
- Supports high contrast mode
Integration with CometChatConversations
The CometChatConversationItem is designed to work seamlessly within CometChatConversations:itemView template that uses CometChatConversationItem:
Best Practices
The component uses
OnPush change detection strategy. If you’re passing objects that change internally, ensure you create new object references to trigger change detection.Related Components
- CometChatConversations: Parent component that renders a list of conversation items
- CometChatAvatar: Avatar component used in the leading section
- CometChatDate: Date formatting component used for timestamps
- CometChatContextMenu: Context menu component for conversation actions
Technical Details
- Standalone Component: Can be imported and used independently
- Change Detection: Uses
OnPushstrategy for optimal performance - Bundle Size: Lightweight, focused component
- Dependencies: CometChatAvatar, CometChatDate, CometChatContextMenu, TranslatePipe
- BEM CSS: Follows Block Element Modifier naming convention
- Accessibility: WCAG 2.1 Level AA compliant