Skip to main content

Where It Fits

CometChatSearch is a standalone search panel that searches across conversations and messages simultaneously. It renders filter chips, conversation results, and message results in a unified interface. Wire onConversationClicked and onMessageClicked to navigate to the selected result.

Minimal Render

Root CSS class: .cometchat-search

Filtering Search Results

Search Scope

Control which entities are searched using searchIn with CometChatSearchScope.

Search Filters

Control which filter chips appear using searchFilters with CometChatSearchFilter.

Request Builders

Pass ConversationsRequestBuilder and MessagesRequestBuilder to customize the underlying SDK queries.

Scoped Search (User or Group)

Limit search to a specific user or group conversation using uid or guid.

Actions and Events

Callback Props

onConversationClicked

Fires when a conversation is clicked in search results.

onMessageClicked

Fires when a message is clicked in search results.

onBack

Fires when the back button is clicked.

onError

Fires on internal errors during search.

Global UI Events

The CometChatSearch component does not emit any custom UI events.

SDK Events (Real-Time, Automatic)

The component does not attach SDK listeners. Search is on-demand, not real-time.

Custom View Slots

The component exposes separate view slots for conversation results and message results. All per-item slots receive their respective data object. Conversation view slots follow the same pattern as CometChatConversations. Refer to that component for detailed examples.

messageItemView

Replace the entire message list item in search results.

messageLeadingView

Replace the message avatar / left section.

messageTitleView

Replace the message title text.

messageSubtitleView

Replace the message subtitle text.

messageTrailingView

Replace the message right section.

messageSentAtDateTimeFormat

Customize the message timestamp format using a CalendarObject.

Common Patterns

Photos and videos filter only

Search within a specific group


CSS Architecture

The component uses CSS custom properties (design tokens) defined in @cometchat/chat-uikit-react/css-variables.css. The cascade:
  1. Global tokens set on the .cometchat root wrapper.
  2. Component CSS (.cometchat-search) consumes these tokens via var().
  3. Overrides target .cometchat-search descendant selectors.

Key Selectors

Customization Matrix


Props

All props are optional. Sorted alphabetically.

conversationItemView

Custom renderer for the entire conversation list item in search results.

conversationLeadingView

Custom renderer for the conversation avatar / left section.

conversationOptions

Custom context menu actions for conversation items.

conversationsRequestBuilder

Controls which conversations appear in search results.

conversationSubtitleView

Custom renderer for the conversation subtitle.

conversationTitleView

Custom renderer for the conversation title.

conversationTrailingView

Custom renderer for the conversation trailing section.

emptyView

Custom component displayed when no search results are found.

errorView

Custom component displayed when an error occurs.

guid

Limits search to messages in a specific group.

hideBackButton

Hides the back button.

hideGroupType

Hides the group type icon in conversation results.

hideReceipts

Hides message read/delivery receipt indicators.

hideUserStatus

Hides the online/offline status indicator.

initialSearchFilter

The filter active by default on load.

initialView

Custom component displayed before the user enters a search query.

loadingView

Custom component displayed during search loading.

messageItemView

Custom renderer for the entire message list item in search results.

messageLeadingView

Custom renderer for the message avatar / left section.

messageSentAtDateTimeFormat

Format for message timestamps. Falls back to global calendar configuration if not set.

messagesRequestBuilder

Controls which messages appear in search results.

messageSubtitleView

Custom renderer for the message subtitle.

messageTitleView

Custom renderer for the message title.

messageTrailingView

Custom renderer for the message trailing section.

onBack

Callback fired when the back button is clicked.

onConversationClicked

Callback fired when a conversation is clicked in search results.

onError

Callback fired when the component encounters an error.

onMessageClicked

Callback fired when a message is clicked in search results.

searchFilters

Filters rendered in the search filter bar.

searchIn

Scopes to search in.

textFormatters

Custom text formatters for message content.

uid

Limits search to messages with a specific user.

Events

The CometChatSearch component does not emit any custom UI events.

CSS Selectors