1.0.2 • Published 7 years ago

selectron-react v1.0.2

Weekly downloads
3
License
MIT
Repository
-
Last release
7 years ago

Selectron React

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

I built this select replacement as I was frustrated with the UX other react select replacements offered. I found other solutions over engineered, complicated to use and ultimatley not user friendly.

See some examples / docs at https://dahliacreative.github.io/selectron-react/

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

Options

PropTypeRequiredDefaultDescription
optionsarrayYes[]an array of option objects, requires value and label params
valueobject/arrayNonullan option object / array of option objects, requires value and labelparams
onChangefunctionYes() => {}a function to be called when the select changes, recieves value as param
onSearchfunctionNoa function to be called when the user searches, recieves term as param. used for ajaxing in options
multiboolNofalseallow multiple options
placeholderstringNoPlease select...placeholder to display
clearableboolNotrueallows user to clear value once an option is selected
searchableboolNotrueallows user to filter the options list
requiredboolNofalseadds HTML5 required attribute to hidden inputs
namestringNoselectron-react-valueHTML name attribute add to hidden fields

License

Copyright (c) 2017 Simon Sturgess

Licensed under the MIT license.