Skip to main content

Overview

CometChatConversations is a sidebar list component. It renders recent conversations for the logged-in user and emits the selected CometChat.Conversation via onItemClick. Wire it to CometChatMessageHeader, CometChatMessageList, and CometChatMessageComposer to build a standard two-panel chat layout.
Live Preview — interact with the default conversations list.Open in Storybook ↗
The component handles:
  • Paginated fetching with infinite scroll
  • Real-time updates (new messages, typing indicators, presence changes)
  • Search filtering
  • Selection mode (single/multiple)

Usage

Flat API

Compound Composition

Full Layout Example


Filtering

Pass a CometChat.ConversationsRequestBuilder to conversationsRequestBuilder to control which conversations load. Pass the builder instance — not the result of .build().
The component includes a built-in search bar. When the user types, it filters conversations client-side by name. For server-side search, pass a searchRequestBuilder:
To use the search bar as a trigger for a custom search UI (like CometChatSearch), pass onSearchBarClicked:

Filter Recipes


Actions and Events

Callback Props

Events Emitted

UI events this component publishes:

Events Received

UI events this component subscribes to (published by other components):

SDK Listeners (Automatic)

These SDK listeners are attached internally. The component updates its state automatically — no manual subscription needed:
  • Message listeners: onTextMessageReceived, onMediaMessageReceived, onCustomMessageReceived, onInteractiveMessageReceived
  • Typing: onTypingStarted, onTypingEnded
  • Receipts: onMessagesDelivered, onMessagesRead
  • Presence: onUserOnline, onUserOffline
  • Groups: onGroupMemberJoined, onGroupMemberLeft, onGroupMemberKicked, onGroupMemberBanned, onMemberAddedToGroup

Customization

View Props

Use view props to replace sections of the default UI while keeping the component’s behavior intact:

itemView

Replace the entire list item row. Default:
Customized:

leadingView

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

titleView

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

subtitleView

Replace the last message preview text. Default:
Customized:

trailingView

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

headerView

Replace the entire header bar.

Compound Composition

For full layout control, use sub-components. Omit any sub-component to hide it:
Available sub-components:

CSS Styling

Override design tokens on the component selector:

Props

All props are optional.
View slot props (headerView, searchView, loadingView, emptyView, errorView, itemView, leadingView, titleView, subtitleView, trailingView) are convenience props available only on the flat API. In compound composition mode, use the corresponding sub-components directly.

conversationsRequestBuilder

Custom request builder for fetching conversations. Controls pagination, filtering, and sorting.

searchRequestBuilder

Custom request builder used specifically when the user searches. Separate from the main builder.

searchKeyword

Initial search keyword to pre-filter conversations on mount.

activeConversation

The currently active/highlighted conversation. The matching item receives an active visual state.

lastMessageDateTimeFormat

Custom date/time format for the last message timestamp shown in each conversation item.

hideReceipts

Hide message delivery/read receipts (double ticks) on conversation items.

hideUserStatus

Hide the online/offline status indicator on user avatars.

hideGroupType

Hide the group type indicator (public/private/password) on group conversation items.

hideUnreadCount

Hide the unread message count badge.

hideDeleteConversation

Hide the delete option in the conversation item’s context menu.

showSearchBar

Whether to show the search bar. Set to false to hide it entirely.

showScrollbar

Show the native scrollbar on the conversation list.

selectionMode

Enable selection mode for multi-select operations.

disableSoundForMessages

Disable the notification sound when new messages arrive.

customSoundForMessages

Custom sound URL to play when new messages arrive (replaces the built-in sound).

onItemClick

Callback when a conversation item is clicked.

onSelect

Callback when a conversation is selected or deselected (only fires in selection mode).

onError

Callback when an SDK error occurs during fetch or real-time operations.

onEmpty

Callback when the conversation list is empty after the initial fetch completes.

onSearchBarClicked

Callback when the search bar is clicked. When provided, the search input becomes read-only and acts as a trigger (useful for opening a global search component like CometChatSearch).

CSS Architecture

The component uses CSS custom properties (design tokens) that are bundled with @cometchat/chat-uikit-react. 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


Next Steps

Users

Browse and select users for new conversations

Message List

Display messages for the selected conversation

Search

Search across conversations and messages

Theming

Customize colors, fonts, and spacing