This is a select component, provide hot search
, clean
, show the number of items
. It is simple to use.
live demo
npm i --save react-awesome-select
And in you component
import { AwesomeSelect } from 'react-awesome-select';
class Select extends React.Component {
contructor() {
super();
this.state = {
data: [
{ name: `China`, value: 1, selected: true },
{ name: `Australia`, value: 2 },
{ name: `Austria`, value: 3 },
{ name: `Belgium`, value: 4 },
{ name: `Canada`, value: 5 },
{ name: `Denmark`, value: 6 },
{ name: `Ecuador`, value: 7 },
{ name: `Egypt`, value: 8 },
{ name: `Finland`, value: 9 },
{ name: `France`, value: 10 },
{ name: `Georgia`, value: 11 },
{ name: `Germany`, value: 12 },
{ name: `Greece`, value: 13 },
{ name: `Hungary`, value: 14 },
{ name: `Iceland`, value: 15 },
{ name: `India`, value: 16, selected: true },
{ name: `Iran`, value: 17, selected: true },
{ name: `Italy`, value: 18, selected: true }
]
};
}
render() {
return (
<AwesomeSelect
style={{ width: '400px' }}
data={this.state.data}
mult
onChange={(value, name, allChoose) => console.log(`---`, value, name, allChoose)}
/>
);
}
}
props | type |
---|---|
data | Array(isRequired) |
mult | Bool(default: false) |
style | object |
onChange | function(isRequired) |
onBlur | function |
const data = [{
name: 'Stephen.Kingsley',
value: 1,
selected: true
}];
params | type |
---|---|
value | string |
name | string |
allChoose | object |
git clone https://github.com/stephenkingsley/react-select.git
cd react-select
npm install
npm start