Signature
About this widget
TheSearchBox is used to perform a text-based query.
To add a SearchBox to your search experience, use these components:
Searcher. TheSearcherthat handles your searches.SearchBoxViewModel. The business logic that handles new search inputs.SearchBoxView. The view that handles the input.
Examples
Kotlin
Parameters
The business logic that handles new search inputs.
Defines the event triggering a new search.
SearchMode.AsYouType. Triggers a search on each keystroke.SearchMode.OnSubmit. Triggers a search on submitting the query.
Delays searcher operations by a specified time duration.
Controls whether the
Searcher automatically runs a search when the query changes. When true (default), typing or submitting updates the query and triggers a search. When false, the query updates but no search is sent until you trigger it manually, giving you full control over when searches occur.View
The view that handles the input.
Kotlin
Compose UI
InstantSearch providesSearchBoxState as a state model, which is an implementation of the SearchBoxView interface.
You need to connect SearchBoxState to the SearchBoxConnector or SearchBoxViewModel like any other SearchBoxView implementation,
and create a Compose UI view that handles the query input, you can directly use the SearchBoxState as a state model,
It provides the query property along with the setText function to streamline the design process of your custom Compose UI view.
Kotlin