Get Started

A react module to create suggestions in search input component.

$ npm install @anujsharma141/reactsearch
import Search from "@anujsharma141/reactsearch"
Props
data
Pass an array of objects of strings or objects on which the search is to be index.
function App() {
const names = ['blue' , 'black' , 'brown','berrys' , 'baguettes']
return (
<Search data={names} />
)
}
select
This method triggers when user selects an option from the search suggestions.
function App() {
const req = link => axios.request(`https://api.abc.com/name?${link} `)
return (
<Search data={state} select={req} />
)
}
submit
This method triggers when user submits the input form.
function App() {
const req = link => axios.request(`https://api.abc.com/name?${link} `)
return (
<Search data={state} submit={req} />
)
}
placeholder
Placeholder of the searchbar.
function App() {
return (
<Search data={state} placeholder="search" />
)
}
maximum
Limits the search suggestion to a maximum number of suggestions.
function App() {
return (
<Search data={state} maximum="5" />
)
}
Style

Cusomise the component by writing css for the following classnames.

searchbar
class of input element
searchlist
class of dropdown suggestion list
searchitem
class of suggestion list item