0.2.3 • Published 2 years ago

custom-react-search-field v0.2.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

custom-react-search-field

Package: https://www.npmjs.com/package/custom-react-search-field

Demo: https://maheshudvag.github.io/react-custom-search-field/

Props

propTypeDescription
onInputfunctionCallback function invoked when search text is updated.
debounceOnChangebooleanflag to determine whether to use debounce function when search text is updated.
delaynumbernumber of milliseconds to wait to call the callback function when search text is updated.
displayIconbooleanflag to determine whether to show the icon or not.
onKeyPressHandlerfunctionCallback function called when a key is pressed. (e.g - can be used to call/redirect to a page on click of enter key)
onIconClickHandlerfunctionCallback function called on click of the icon
IconHTMLElementElement to be shown instead of the default search icon.
searchTermStringDefault search term
placeholderStringPlaceholder text

Installation

npm i custom-react-search-field

Usage

import SearchBar from "custom-react-search-field";

<SearchBar
 onInput={(value) => console.log("onInput", value)}
 debounceOnChange={debounceOnChange}
 delay={300}
 displayIcon={showIcon}
 onKeyPressHandler={(value) => console.log("onKeyPress", value)}
 onIconClickHandler={(value) => console.log("onIconClick", value)}
 Icon={<i className="fa fa-search" aria-hidden="true"></i>}
/>

License

MIT Licensed. Copyright (c) 2022 R MAHESH UDVAG