spmjs

spm@3.x

Brand new static package manager for browser.

Getting Started 󰅴 Packages

react-radio


React RadioGroup

spm install react-radio
Versions 1.0.8, 1.0.7
Updated 9 years ago
Keywords radio, input, radio-group, react, react-component
Homepage https://github.com/zippyui/react-radio
Repository https://github.com/zippyui/react-radio.git
Dependencies react, object-assign
Main lib/index.js
Owner

react-radio

A carefully crafted radio-group for React

See demo at zippyui.github.io/react-radio

Install

$ npm install react-radio

Usage

var RadioGroup = require('react-radio')

var colors = [
    {
        value: 'red',
        label: 'Red color',
        style: {
            color: 'red'
        }
    },
    'blue',
    'orange'
]

function onChange(value, event){
    console.log('checked ', value)
}

//uncontrolled
<RadioGroup
    name="colors"
    defaultValue={'red'}
    items={colors}
    onChange={onChange}
/>

var COLOR = 'red'
//controlled
<RadioGroup name="colors" value={COLOR} items={colors} onChange={onChange} />

<RadioGroup name="colors" value={'red'} onChange={onChange}>
    <input type="radio" value="blue" />blue
    <input type="radio" value="red" />red
</RadioGroup>

Props

If you have a ref to the react-radio component, you can also call group.getValue() to get the current value of the radio group.

Changelog

See changelog

Contributing

Use Github issues for feature requests and bug reports.

We actively welcome pull requests.

For setting up the project locally, use:

$ git clone https://github.com/zippyui/react-radio
$ cd react-radio
$ npm install
$ npm serve # to start http server
$ npm dev   * to start webpack-dev-server

Now navigate to localhost:9091

Before building a new version, make sure you run

$ npm run build

which compiles the src folder (which contains jsx files) into the lib folder (only valid EcmaScript 5 files).

License

MIT