A simple select replacement component built with & for React.Js
Follow @dahliacreative Watch Star Fork Issuenpm install selectron-react
yarn add selectron-react
<Selectron
options={[{
value: 'England',
label: 'England'
},{
value: 'Wales',
label: 'Wales'
},{
value: 'Scotland,
label: 'Scotland'
},{
value: 'Northern Ireland',
label: 'Northern Ireland'
}]}
onChange={(value) => {this.setState({value})}}
value={this.state.value}/>
Prop | Type | Required | Default | Description |
---|---|---|---|---|
options
|
array
|
Yes |
[]
|
an array of option objects, requires value and label params |
value
|
object / array
|
No |
null
|
an option object / array of option objects, requires value and label params |
onChange
|
function
|
Yes |
() => {}
|
a function to be called when the select changes, recieves value as param |
onSearch
|
function
|
No |
a function to be called when the user searches, recieves term as param. used for ajaxing in options |
|
multi
|
bool
|
No |
false
|
allow multiple options |
placeholder
|
string
|
No |
Please select... |
placeholder to display |
clearable
|
bool
|
No |
true
|
wether the user can clear the select once an option is sselected |
searchable
|
bool
|
No |
true
|
wether the user can search to filter the list |
required
|
bool
|
No |
false
|
adds HTML5 required attribute to inputs |
name
|
string
|
No |
selectron-react-value
|
HTML name attribute added to the hidden input |