cpr-select
v2.7.0
Published
A consistently styled cross-browser and keyboard friendly select component
Downloads
61
Maintainers
Keywords
Readme
cpr-select
Canopy React Select
Requirements
- React ^0.14.2
- Lodash methods findIndex
Installation
- Install through
npm install --save cpr-select
- Load the required stylesheet
src/select.css
- Optional - if you want some default styling use the stylesheet:
build/external-styles.css
Usage
Props
selected
: the key of the currently selected itemoptions
: the items to select from. You can insert a separator between items by putting{separator: true}
as an item. You can also prevent the user from selecting an item by includingdisabled: true
in your item object.onChange
: called when selected item changesonBlur
: called when the select widget is blurred (with the currently selected item)disabled
: pass true to disable the inputplaceholder
: placeholder for inputselectClass
: (optional) custom class to be added to the select elementouterClass
: (optional) custom class to be added to the outer containing elementinputClass
: (optional) custom class to be added to the hidden input elementdropdownClass
: (optional) custom class to be added to the dropdown elementzIndex
: (optional) override the default z-index of 1000
Basic
import CanopySelect from 'cpr-select';
import 'cpr-select/src/select.css';
let items = [
{
"value": "Alabama",
"key": "AL"
}, {
"separator": true,
}, {
"value": "Alaska",
"key": "AK"
}, {
"value": "American Samoa",
"key": "AS",
"disabled": true
}
];
function itemsChanged(key, item, index) {
console.log(key);
}
<CanopySelect options={items} onChange={itemsChanged} placeholder="Select a country" selected="AK"></CanopySelect>
Demo
http://canopytax.github.io/cpr-select/