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 for 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

customize 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