AI Integration Quick Reference
AI Integration Quick Reference
Where It Fits
CometChatUsers is a contact list component. It renders all available users and emits the selected CometChat.User via onItemClick. Wire it to CometChatMessageHeader, CometChatMessageList, and CometChatMessageComposer to build a standard two-panel chat layout.

Minimal Render
.cometchat-users
Filtering Users
Pass aCometChat.UsersRequestBuilder to usersRequestBuilder. Pass the builder instance — not the result of .build().
Filter Recipes
Default page size is 30. The component uses infinite scroll — the next page loads as the user scrolls to the bottom.
A separate
searchRequestBuilder can be passed to filter the search list independently from the main list.
Refer to UsersRequestBuilder for the full builder API.
Actions and Events
Callback Props
onItemClick
Fires when a user row is tapped. Primary navigation hook — set the active user and render the message view.onSelect
Fires when a user is checked/unchecked in selection mode. RequiresselectionMode to be set.
onEmpty
Fires when the user list fetch returns zero results.onError
Fires on internal errors (network failure, auth issue, SDK exception).Global UI Events
The component subscribes toCometChatUserEvents internally:
CometChatUsers does not emit any custom UI events.
SDK Events (Real-Time, Automatic)
The component listens to these SDK events internally. No manual attachment needed unless additional side effects are required.
Automatic: user presence changes (online/offline), blocked/unblocked state.
In React 18 StrictMode,
useEffect runs twice on mount in development. The component handles listener cleanup internally, but any additional listeners added alongside the component need cleanup in the useEffect return function to avoid duplicate event handling.Custom View Slots
Each slot replaces a section of the default UI. Slots that accept a user parameter receive theCometChat.User object for that row.
itemView
Replace the entire list item row. Default:

- TypeScript
- CSS
leadingView
Replace the avatar / left section.
- TypeScript
- CSS
trailingView
Replace the right section.
- TypeScript
- CSS
titleView
Replace the name / title text. Role badge inline example.
- TypeScript
- CSS
subtitleView
Replace the subtitle text for each user. Default:

- TypeScript
- CSS
headerView
Replace the entire header bar.
- TypeScript
- CSS
options
Replace the context menu / hover actions on each user item. Default:

- TypeScript
- CSS
Common Patterns
Custom empty state with CTA
Friends-only list with search
Multi-select with preview strip
Hide all chrome — minimal list
CSS Architecture
The component uses CSS custom properties (design tokens) defined in@cometchat/chat-uikit-react/css-variables.css. The cascade:
- Global tokens (e.g.,
--cometchat-primary-color,--cometchat-background-color-01) are set on the.cometchatroot wrapper. - Component CSS (
.cometchat-users) consumes these tokens viavar()with fallback values. - Overrides target
.cometchat-usersdescendant selectors in a global stylesheet.
CometChatUsers exist on the same page, wrap the component in a container and scope selectors:
Key Selectors
Example: Brand-themed users

Customization Matrix
Props
All props are optional unless noted.activeUser
Highlights the specified user in the list.
Must be a reference-equal object from the SDK; a manually constructed object will not match.
disableLoadingState
Disables the loading state while fetching users.
Useful when updating the request builder without clearing the list.
emptyView
Custom component displayed when there are no users.errorView
Custom component displayed when an error occurs.
Hidden when
hideError={true}.
headerView
Custom component rendered as the entire header bar.hideError
Hides the default and custom error views.
Also suppresses
errorView if set.
hideSearch
Hides the default search bar.hideUserStatus
Hides the online/offline status indicator.itemView
Custom renderer for the entire list item row.leadingView
Custom renderer for the avatar / left section.loadingView
Custom component displayed during the loading state.onEmpty
Callback fired when the user list is empty.onError
Callback fired when the component encounters an error.onItemClick
Callback fired when a user row is clicked.onSelect
Callback fired when a user is selected/deselected. RequiresselectionMode to be set.
options
Custom context menu / hover actions for each user item.searchKeyword
Pre-fills the search and filters the user list.searchRequestBuilder
Request builder with search parameters to fetch users.
If the search input is not empty, the search keyword of this request builder is set to the text in the search input.
sectionHeaderKey
The property on the user object used to extract the section header character.
Only relevant when
showSectionHeader={true}.
selectionMode
Enables single or multi-select checkboxes on list items.onSelect to capture selections.
showScrollbar
Shows the scrollbar in the user list.showSectionHeader
Displays alphabetical section headers (A, B, C…).showSelectedUsersPreview
Shows a preview strip of selected users whenselectionMode is multiple.
Each chip displays avatar, name, and a close button to remove the user.
subtitleView
Custom renderer for the subtitle text.titleView
Custom renderer for the name / title text.trailingView
Custom renderer for the right section.usersRequestBuilder
Controls which users load and in what order.
Pass the builder instance, not the result of
.build().
Events
CometChatUsers does not emit custom UI events. It subscribes to: