import * as React from 'react'import { Search } from '@welcome-ui/search'type Item = { Title: string }const Example = () => {const searchFunction = async (s: string) => {const response = await fetch(`https://www.omdbapi.com?apikey=41514363&s=${s}`)const data = await response.json()return data.Search}return (// TODO: fix typescript// eslint-disable-next-line @typescript-eslint/ban-ts-comment// @ts-ignore<SearchitemToString={(item: Item) => item && item.Title}name="movies"placeholder="Search a movie"renderItem={(item: Item) => (<div style={{ display: 'flex', alignItems: 'center' }}>{item.Title}</div>)}search={searchFunction}/>)}export default Example
Installation
1
Run the following command:
yarn add @welcome-ui/search
2
Import component:
import { Search } from '@welcome-ui/search'
With option groups
To use option groups, you must provide two additional props: groupsEnabled
that allow nested options and renderGroupHeader
that renders the header of a specific group