CometChatSearch searches conversations and messages together. A search field, a rail
of filter chips and two result sections — Chats above, Messages below — each paginating as
you scroll.

Where It Fits
CometChatSearch is the way into everything already said. It is a whole screen with its
own field, not a list you embed, and it hands you back an SDK model to navigate with.
- SwiftUI
- UIKit
Quick Start
- SwiftUI
- UIKit
Nothing is fetched until there is something to search for. With no text and no chip
selected the screen shows its initial state, which is a separate state from “no
results” and has its own slot and its own flag.
Scoping a Search
One half only
- SwiftUI
- UIKit
Inside one conversation
- SwiftUI
- UIKit
uid wins if you set both.Filtering the request
- SwiftUI
- UIKit
Each closure is called fresh for every fetch, so return a new builder each time
rather than capturing one instance. A request builder is consumed by building: one
shared instance would hand every page the same pagination cursor.
The Filter Chips
Seven chips, in this order: Unread, Groups, Photos, Videos, Links, Documents, Audio. They belong to four families, and the families are the whole behaviour:
Select one chip and the rail collapses to that chip’s family — the other families stop
being drawn. Within a family chips combine, so Photos and Videos can both be on. Selecting a
filter also lifts the three-row preview and suppresses “Show More”, because a filtered
search is already the thing you asked for.
Deselecting the last chip restores all seven.
Choosing which chips exist
- SwiftUI
- UIKit
initialSearchFilter pre-selects one. It is ignored if it is not in searchFilters.Hiding the rail
- SwiftUI
- UIKit
Result Sections
Two sections, fixed order:
A message row’s kind is decided once, centrally, from the message itself — so a hit with a
URL in it renders as a link row in both toolkits, and an action, a card, a custom or an
interactive message all render as text rows.
Each section pages independently: three rows while you have typed text and no chip, a full
page otherwise, with “Show More” on a section that has more.
- SwiftUI
- UIKit
The matched keyword is highlighted in titles and subtitles, every occurrence,
case-insensitively.
Actions and Events
Callback Methods
- SwiftUI
- UIKit
The two click callbacks hand back SDK models, so you can navigate with them directly.
The two load callbacks hand back the value types the rows render, and fire on every
emission — including the empty one when the field is cleared.
onBack also decides who draws the back button. Leave it nil and the screen relies on the
navigation stack it is pushed onto, exactly as a system screen would. Set it and the Kit
draws its own chevron in the bar, hides the system’s, and calls your closure.Global Events
The screen raises nothing on the event buses. Navigation is yours, through the callbacks or, in UIKit, the delegate.SDK Events (Real-Time, Automatic)
Search registers no SDK listeners. A result row is a snapshot of the moment it was fetched: a message edited or deleted afterwards keeps its old text until the next search. That is deliberate.- SwiftUI
- UIKit
There is nothing to connect or disconnect.
Functionality
- SwiftUI
- UIKit
Custom View Slots
State views
Four states, four slots. The initial state and the no-results state are separate:- SwiftUI
- UIKit
errorView takes no retry argument. The built-in error view ships a real retry
button; a view you supply owns its own retry, because you own the view.Row slots
Eleven slots. The whole conversation row:- SwiftUI
- UIKit
linkMessageItemView only — it does not fall back to
textMessageItemView, even though a link hit is a text message.Replacing the cell
- SwiftUI
- UIKit
Rows are replaced through the row slots above.
Common Patterns
Open the right screen from either section
- SwiftUI
- UIKit
A media picker
- SwiftUI
- UIKit
Chips only, no text, one family:
Search inside one chat
- SwiftUI
- UIKit
A messages-only picker
- SwiftUI
- UIKit
Pass
searchScopes: [.messages] and handle onMessageClick, as in
Scoping a Search.Advanced Methods
Driving the Field
- SwiftUI
- UIKit
Store Access
- SwiftUI
- UIKit
Supply a
SearchStore through searchStore to share state across screens or to seed a
preview.Subclassing
- SwiftUI
- UIKit
CometChatSearch is a View struct. Customise it with its slots and style.Objective-C
- SwiftUI
- UIKit
Objective-C is covered on the UIKit tab.
Style
- SwiftUI
- UIKit
Liquid Glass
The chip rail is chrome, so on iOS 26 and later it renders as Liquid Glass and the results travel behind it. That is why the rail’s height is a content inset rather than a gap: with nothing moving behind the material there is nothing to refract, and the glass would render as a plain fill. It falls back to an opaque rail automatically on earlier systems and whenever Reduce Transparency is on. You do not opt in or out per component.Next Steps
Conversations
The list a search result opens
Message List
Where a message result lands
Users
The directory, for starting a new conversation