Search Box Controller

The SearchBox headless controller offers a high-level interface for designing a common search box UI controller.

Initializer

buildSearchBox

Parameters:

Returns SearchBox

Options

id (String)

A unique identifier for the controller. By default, a unique random identifier is generated.

numberOfSuggestions (Number)

The number of query suggestions to request from Coveo ML (e.g., 3).

Using the value 0 disables the query suggest feature.

Default: 5

Methods

clear

Clears the search box text and the suggestions.

hideSuggestions

Clears the suggestions.

selectSuggestion

Selects a suggestion and calls submit.

Parameters:

  • value: string

    The string value of the suggestion to select

showSuggestions

Shows the suggestions for the current search box value.

submit

Triggers a search query.

updateText

Updates the search box text value and shows the suggestions for that value.

Parameters:

  • value: string

    The string value to update the search box with.

state

The state of the SearchBox controller.

Returns SearchBoxState

Recommended Articles