Filtered multi-select React component
npm install react-filtered-multiselect[![Travis][build-badge]][build]
[![npm package][npm-badge]][npm]
A React component, for making and adding to selections using a filtered multi-select.
Live example with Bootstrap styles applied
!FilteredMultiSelect with Bootstrap styles screenshot
This component manages an , a and a .
You provide a list of objects to be used to populate the select and an onChange callback function.
Typing in the the input will filter the select to items with matching option text.
When some of the select's options are selected, the button will become enabled. Clicking it will select the objects backing the currently selected options.
If only one option is displayed after filtering against the input, pressing Enter in the input will select the object backing it.
When backing objects are selected, the onChange callback is executed, passing a list of all backing objects selected so far.
To hide already-selected items, pass them back to FilteredMultiSelect as its selectedOptions prop. This can be more convenient than manually removing the selected items from the list passed as options.
To deselect items, remove them from the list passed back via the onChange callback and re-render the FilteredMultiSelect with the new list passed as its selectedOptions prop.
Double-clicking will add the selected option to the selection.
Node
```
npm install react-filtered-multiselect
`javascript`
import FilteredMultiSelect from 'react-filtered-multiselect'
// or
const FilteredMultiSelect = require('react-filtered-multiselect')
Browser
Browser bundles export a global FilteredMultiSelect variable and expect to find a global React variable to work with.
* react-filtered-multiselect.js (development version)
* react-filtered-multiselect.min.js (compressed production version)
Minimal usage:
`js
let options = [
{value: 1, text: 'Item One'},
{value: 2, text: 'Item Two'}
]
options={options}
/>
`
options - list of objects providing
The component will update its display if its options list changes length or is replaced with a different list, but it will not be able to detect changes which don't affect length or object equality, such as replacement of one option with another. Consider using immutability-helper or other immutability libraries if you need to do this.
onChange(selectedOptions) - callback which will be called with selected option objects each time the selection is added to.
buttonText - text to be displayed in the
className - class name for the component's
container.classNames - class names for each of the component's child elements. See the default props below for properties. Defaults will be used for any properties not specified via this prop.defaultFilter - default filter text to be applied to the