1.1.0 • Published 5 years ago

search-bar-react v1.1.0

Weekly downloads
18
License
ISC
Repository
-
Last release
5 years ago

search-bar-react

Instagram-inspired react search bar.

Examples

Default:

 

Mobile:

 

Install

npm install search-bar-react --save

Usage

import SearchBar from 'search-bar-react'

...
<SearchBar
	onChange={(text) => console.log(text)}
	onFocus={() => console.log('focused')}
	size='large'
	width='100%'
	autoFocus
	placeholder='Search...'
	onClear={() => console.log('closed')}
	value='Initial Value'
/>
...
<SearchBar
	mobile
	onClear={() => console.log('cleared')}
/>
...

Props

PropTypeDefaultDescription
mobileBooleanfalseUse the mobile style version.
valuestring''Initial Value.
placeholderstring'Search'Search Bar custom placeholder.
clearBtnTextstring'Clear'(mobile version only) custom clear text.
widthstring'280px'Set custom width.
sizestring'default'Select a predefined size ['small','large']
loadingBooleanControl loading button behavior. As default the loading button spins for a second after user input.
autoFocusBooleanfalseAutofocus on mount.
onChangefunctionCallback on input change. Returns string.
onFocusfunctionCallback on input focus.
onClearfunctionCallback on Clear-Button click.

License

MIT Licensed. Copyright (c) Darwin Bonfante 2019.