Overview
The CometChatUserItem component renders a single user entry within a list. It displays the user’s avatar, name, and online/offline status indicator, and supports custom templates for all visual sections. The component integrates a context menu for user-specific actions and provides full keyboard accessibility with ARIA support.Key Features
- State Management: Active, selected, and focused states with distinct visual styling
- User Avatar: Displays the user’s avatar image with an online/offline status indicator
- Custom Templates: Template projection for leading, title, subtitle, and trailing sections
- Context Menu: Configurable context menu options on hover or right-click
- Keyboard Accessibility: Full keyboard support with Enter, Space, and Shift+F10 shortcuts
- Global Config Priority: Supports a three-tier priority system (Input > GlobalConfig > Default)
Live Preview — default user item preview.
Open in Storybook ↗
Basic Usage
Properties
Events
Customization
CSS Variable Overrides
The component uses CometChat CSS variables for theming. Override them on the host element or a parent wrapper:Custom Templates
Provide custom templates via inputs to override any visual section:Accessibility
Keyboard Navigation
ARIA Attributes
role="option"on the item containeraria-selectedreflects the current selection statearia-labelcombines the user name and online/offline status for screen readers- Proper
tabindexmanagement via roving tabindex pattern
Focus Management
- Visible focus indicator meeting WCAG contrast requirements
- Mouse clicks prevent focus outline (focus ring only appears for keyboard navigation)
- Roving tabindex pattern for efficient list navigation
Related Components
- CometChatUsers — Parent list component that renders multiple user items
- CometChatAvatar — Used internally for the user avatar
- CometChatContextMenu — Used internally for the context menu