Skip to content

Instantly share code, notes, and snippets.

@box-turtle
Created March 15, 2016 22:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save box-turtle/1bf202a74ccff5e35892 to your computer and use it in GitHub Desktop.
Save box-turtle/1bf202a74ccff5e35892 to your computer and use it in GitHub Desktop.
import {Dropdown} from 'react-bootstrap';
import {SelectList} from 'react-widgets';
const selectData = ['Red', 'Blue', 'Green'];
export default class extends Component {
constructor(props) {
super(props);
this.state = {
selectedColors: []
};
}
onValueChange = (values) => {
this.setState({selectedColors: values});
}
render() {
const {selectedColors} = this.state;
const selectListLabel = selectedColors.length ? selectedColors.join(', ') : 'Select a Color';
return (
<Dropdown id="multiselect">
<Dropdown.Toggle>
{selectListLabel}
</Dropdown.Toggle>
<Dropdown.Menu>
<div onClick={(e) => e.stopPropagation}>
<SelectList data={selectData} multiple
value={selectedColors}
onChange={this.onValueChange}
style={{border: 'none'}}/>
</div>
</Dropdown.Menu>
</Dropdown>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment