Skip to main content

Where It Fits

CometChatConversations is a sidebar list component. It renders recent conversations and emits the selected CometChat.Conversation via onItemClick. Wire it to CometChatMessageHeader, CometChatMessageList, and CometChatMessageComposer to build a standard two-panel chat layout.
Open in CodeSandbox

Minimal Render

Root CSS class: .cometchat-conversations

Filtering Conversations

Pass a CometChat.ConversationsRequestBuilder to conversationsRequestBuilder. 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. Refer to ConversationRequestBuilder for the full builder API.

Actions and Events

Callback Props

onItemClick

Fires when a conversation row is tapped. Primary navigation hook — set the active conversation and render the message view.

onSelect

Fires when a conversation is checked/unchecked in multi-select mode. Requires selectionMode to be set.

onError

Fires on internal errors (network failure, auth issue, SDK exception).

onSearchBarClicked

Fires when the search bar is clicked. Requires showSearchBar={true}.

Global UI Events

CometChatConversationEvents emits events subscribable from anywhere in the application. Subscribe in a useEffect and unsubscribe on cleanup. When to use: sync external UI with conversation state changes. For example, update an unread count badge in a tab bar when ccMarkConversationAsRead fires, or remove a conversation from a custom sidebar when ccConversationDeleted fires.

SDK Events (Real-Time, Automatic)

The component listens to these SDK events internally. No manual attachment needed unless additional side effects are required. Automatic: new messages, typing indicators, receipts, user presence, group membership changes. Manual: deleting a conversation via the SDK directly (not through the component’s context menu) requires emitting CometChatConversationEvents.ccConversationDeleted for the UI to update.
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 conversation parameter receive the CometChat.Conversation object for that row.

itemView

Replace the entire list item row. Default:
Customized:

leadingView

Replace the avatar / left section. Typing-aware avatar example.

trailingView

Replace the timestamp / badge / right section. Relative time badge example.

titleView

Replace the name / title text. Inline user status example.

subtitleView

Replace the last message preview text. Default:
Customized:

headerView

Replace the entire header bar.

options

Replace the context menu / hover actions on each conversation item. Default:
Customized:

textFormatters

Custom text formatters for the conversation subtitle. Array of CometChatTextFormatter instances. If not provided, default formatters from the data source are used.
See CometChatMentionsFormatter for mention formatting.

lastMessageDateTimeFormat

Customize the last message timestamp format using a CalendarObject.
If no property is passed in the CalendarObject, the component checks the global configuration first. If also missing there, the component’s default formatting applies.

Common Patterns

Custom empty state with CTA

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:
  1. Global tokens (e.g., --cometchat-primary-color, --cometchat-background-color-01) are set on the .cometchat root wrapper.
  2. Component CSS (.cometchat-conversations) consumes these tokens via var() with fallback values.
  3. Overrides target .cometchat-conversations descendant selectors in a global stylesheet.
To scope overrides to a single instance when multiple CometChatConversations exist on the same page, wrap the component in a container and scope selectors:
Overrides survive component updates because the component never sets inline styles on these elements — all styling flows through CSS classes and custom properties.

Key Selectors

Example: Brand-themed conversations

Customization Matrix


Props

All props are optional. Sorted alphabetically.

activeConversation

Highlights the specified conversation in the list. Must be a reference-equal object from the SDK; a manually constructed object will not match.

conversationsRequestBuilder

Controls which conversations load and in what order. Pass the builder instance, not the result of .build().

customSoundForMessages

URL to a custom audio file for incoming message notifications. Must be a valid audio URL accessible from the browser.

disableSoundForMessages

Disables the notification sound for incoming messages.

emptyView

Custom component displayed when there are no conversations.

errorView

Custom component displayed when an error occurs. Hidden when hideError={true}.

headerView

Custom component rendered as the entire header bar.

hideDeleteConversation

Hides the delete option in the context menu.

hideError

Hides the default and custom error views. Also suppresses errorView if set.

hideGroupType

Hides the group type icon (public/private/password).

hideReceipts

Hides message read/delivery receipt indicators.

hideUserStatus

Hides the online/offline status indicator.

itemView

Custom renderer for the entire list item row.

lastMessageDateTimeFormat

Format for displaying the timestamp of the last message.
Falls back to global calendar configuration if not set.

leadingView

Custom renderer for the avatar / left section.

loadingView

Custom component displayed during the loading state.

onError

Callback fired when the component encounters an error.

onItemClick

Callback fired when a conversation row is clicked.

onSearchBarClicked

Callback fired when the search bar is clicked. Requires showSearchBar={true}.

onSelect

Callback fired when a conversation is selected/deselected. Requires selectionMode to be set.

options

Custom context menu / hover actions for each conversation item.

searchView

Custom search bar component in the header.

selectionMode

Enables single or multi-select checkboxes on list items.
Must pair with onSelect to capture selections.

showScrollbar

Shows the scrollbar in the conversation list.

showSearchBar

Shows a search bar at the top of the list.

subtitleView

Custom renderer for the last message preview text.

textFormatters

Custom text formatters for the conversation subtitle. See CometChatMentionsFormatter for mention formatting.

titleView

Custom renderer for the name / title text.

trailingView

Custom renderer for the timestamp / badge / right section.

Events

All events are Subject<CometChat.Conversation> from RxJS. Subscribe with .subscribe(), unsubscribe with the returned subscription’s .unsubscribe().

CSS Selectors