React Select Search
React powered selectbox with filter using fuse.js (Javascript fuzzy-search).
Example design comes from the beautiful work by Rovane Durso.
Note!
A React 0.12.* supported version can be found in 0.2.* (and below) tagged releases
Demo
Live demo can be found here: http://tbleckert.github.io/react-select-search/
How to use
Install it with npm (npm install react-select-search --save
) and require it like you normally would.
React.render(
<SelectSearch
name="country"
value="SE"
placeholder="Choose country"
search={true}
multiple={false}
height={height in pixels, used if multiple select}
className="my-selectbox"
options={objectWithOptions}
fuse={fuseJsOptions}
optionSelected={callbackWhenOptionMarked}
valueChanged={callbackWhenValueChanged}
renderOption={modifyOptionHtml}
onMount={componentDidMountCallback}
onFocus={searchFocusCallback}
onBlur={searchBlurCallback} />,
document.getElementById('selectSearch')
);
These are all available options. The React component renders a hidden field with the name property and the current value to use in forms.
You will also need some CSS to make it look right. The important piece is the options.
.select-search-box__select {
display: none;
}
.select-search-box--multiple .select-search-box__select {
display: block;
}
.select-search-box__select--display {
display: block;
}
.select-search-box__select--prehide {
opacity: 0;
}
.select-search-box__options {
}
.select-search-box__option {
}
.select-search-box__option--selected {
}
.select-search-box__option--hover, .select-search-box__option:hover {
}