Skip to main content

io.search

Allows searching for arbitrary results from a search box.

Usage

const user = await io.search("Search for a user", {
renderResult: user => ({
label: user.name,
description: user.email,
imageUrl: user.avatar,
}),
onSearch: async query => {
return users.find(query);
},
});
interval.com

Props

helpTextOptional stringOptional label providing additonal context.
initialResultsRequired array of objectsArray of underlying data object, can be anything.
onSearchRequired async functionReceives a search query string as argument, returns arbitrary data objects.
placeholderOptional stringText to display in the input when no value is set.
renderResultRequired functionReceives a single data object from `onSearch` as argument, must return either a string, or an object with a required `label` property and optional `description` and `imageUrl` properties.

Returns: The underlying result object that was selected.

Was this section useful?
On this page