React RadioGroup

Downloads in past


2.1.28 years ago9 years agoMinified + gzip package size for react-radio in KB


A carefully crafted radio-group for React

See demo at


$ npm install react-radio --save


var RadioGroup = require('react-radio')

var colors = [
        value: 'red',
        label: 'Red color',
        style: {
            color: 'red'

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


var COLOR = 'red'
<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


name: String - the name to be set to all radios in the group value/defaultValue - the value that should be checked in the group (controlled/uncontrolled) labelStyle - a style for the radio label disabledStyle|disabledLabelStyle - a style for the radio label, when disabled inputStyle - a style for the radio input
checkedLabelStyle - a style for the checked radio label checkedInputStyle - a style for the checked radio input disabledInputStyle - a style for the disabled radio input
onChange: Function(value, event) - the function to be calle when the radio group value changes. NOTE: first param sent to this function is the new value, not the event object, as usual
renderRadio: Function(props, index, arr) - you can customize how each radio item is rendered in the group using this function. NOTE: it is called with 3 params, so not intended to be directly used with a React factory.
Example: ```jsx
<RadioGroup renderRadio={React.DOM.label} />

//BUT like this
function renderRadio(props, index, arr){
    return <label {...props} />

<RadioGroup renderRadio={renderRadio} />

function renderRadio(props, index, arr){
    if (index < arr.length - 1){ = '1px solid blue'
    } = 'block'
    //we can skip returning something
    //if we only want to modify props/styles
If the renderRadio function returns undefined, we assume you just wanted to modify the props before rendering, which is ok, so we fallback to the default implementation: <label {...props}/>
items: Array
The items prop can be an array of strings/objects or mixed. If an array of strings, the strings will be used as both value and label. If objects, `item.value` will be used as a value, and `item.label` as a radio label:

    var items = [
        {label: 'Green', value: 'green'},
        {label: <b>Blueish</b>, value: 'blue'},
        {value: 'red'} //'red' will be used as both value and label

    var items = ['green', 'blue', 'red']

If an array item is an object, besides `value` and `label`, it can also have a `style` property, a `checkedStyle` property, and a `disabled` property.

var items = [
        label: 'Blue',
        value: 'blue',
        disabled: true,
        disabledStyle: { color: 'gray' },
        style: { color: 'blue'},
        checkedStyle: { color: 'blue', background: 'red'}
children - if the RadioGroup component specifies children, the radio group children will not be generated from items, but will be what you specify in the children prop
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.


See changelog


Use Github issues for feature requests and bug reports.
We actively welcome pull requests.
For setting up the project locally, use:
$ git clone
$ cd react-radio
$ npm install
$ npm run dev 

Now navigate to localhost:9191
Before building a new version, make sure you run
$ npm run build
which compiles the src folder (which contains jsx syntax) into the lib folder (only valid EcmaScript 5 files).