Selectron React

A simple select replacement component built with & for React.Js

Follow @dahliacreative Watch Star Fork Issue

Installation

npm install selectron-react

or

yarn add selectron-react

Usage

<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}/>

Default Select

Props
options, value, onChange

Default Select, ajaxed options

Props
options, value, onChange, onSearch

Multi Select

Props
multi, options, value, onChange

Multi Select, ajaxed options

Props
multi, options, value, onChange, onSearch

Options

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