react-multiselect-listbox
Version:
A multiple selection list box component for React
92 lines (70 loc) • 2.08 kB
Markdown
for <a href="https://reactjs.org/" target="_blank">React</a>.

- Basic <a href="https://codesandbox.io/s/multi-select-listbox-example-lgvdf?file=/src/App.js" target="_blank">example</a> with dnd sorting
`npm install react-multiselect-listbox --save`
Then, you can import react-multiselect-listbox in your app as follows:
```js
import MultiSelectListBox from 'react-multiselect-listbox'
```
```js
<MultiSelectListBox
overrideStrings={{
search: 'Search...',
selectAll: 'Add All',
removeAll: 'Remove All',
selectedInfo: 'Items selected'
}}
options={[
{ desc: 'item 1', value: 1 },
{ desc: 'item 2', value: 2 }
]}
textField="desc"
valueField="value"
value={selectedTwo}
rowHeight={25}
onSelect={({ item }) => {}}
onRemove={({ item }) => {}}
onSelectAll={selectedItems => {}}
onRemoveAll={() => setSelectedTwo([])}
sortable={true}
onSort={({ sortedList }) => {}}
onSearch={(items ,textField, query) => []}
/>
```
Custimize text messages by passing prop overrideStrings
```js
<MultiSelectListBox
overrideStrings={{
search: 'Search...',
selectAll: 'Add All',
removeAll: 'Remove All',
selectedInfo: 'Items selected'
}}
...
```
Override CSS Variables
```css
:root {
--mslb-bg-color:
--mslb-font-color:
--mslb-border-color:
--mslb-btn-font-color:
--mslb-btn-bg-add-color:
--mslb-btn-bg-remove-color:
--mslb-item-hover-bg-color:
}
```
- This component gets some pieces of logical code from [react-multi-select-component](https://github.com/harshzalavadiya/react-multi-select-component/)
- [react-window](https://github.com/bvaughn/react-window)
- [react-beautiful-dnd](https://github.com/atlassian/react-beautiful-dnd)
- <a href="">Federico Vicente</a> for help with the styles.
MIT Licensed.
A multiselect list box component