|
1 |
| -# radio group |
| 1 | +# Radio buttons |
| 2 | + |
| 3 | +[Radio buttons](https://www.google.com/design/spec/components/selection-controls.html#selection-controls-radio-button) allow the user to select one option from a set. Use radio buttons for exclusive selection if you think that the user needs to see all available options side-by-side. Otherwise, consider a dropdown, which uses less space than displaying all options. They should always be used along with `RadioGroup`. |
| 4 | + |
| 5 | +<!-- example --> |
| 6 | +```jsx |
| 7 | +import { RadioGroup, RadioButton } from 'react-toolbox'; |
| 8 | + |
| 9 | +const RadioTest = () => ( |
| 10 | + <RadioGroup ref='group' name='comic' value='vvendetta'> |
| 11 | + <RadioButton label='The Walking Dead' value='thewalkingdead'/> |
| 12 | + <RadioButton label='From Hell' value='fromhell' disabled/> |
| 13 | + <RadioButton label='V for a Vendetta' value='vvendetta'/> |
| 14 | + <RadioButton label='Watchmen' value='watchmen'/> |
| 15 | + </RadioGroup> |
| 16 | +); |
| 17 | +``` |
| 18 | + |
| 19 | +## Radio Group |
| 20 | + |
| 21 | +A radio selector is mean to get a value from a set of choices, that's why a radio group is needed. It can take some properties and actions that will be transferred to the children, but they also can behave independently. |
| 22 | + |
| 23 | +| Name | Type | Default | Description| |
| 24 | +|:-----|:-----|:-----|:-----| |
| 25 | +| `className` | `String` | `''` | Set a class to give custom styles to the group.| |
| 26 | +| `disabled` | `Boolean` | `false` | If true, the group will be displayed as disabled.| |
| 27 | +| `name` | `String` | | Name for the input element group. | |
| 28 | +| `onChange` | `Function` | | Callback function that will be invoked when the value changes. | |
| 29 | +| `value` | `Any` | | Default value selected in the radio group. | |
| 30 | + |
| 31 | +This component has state to keep the currently selected value and that's why it exposes to methods to work from the code with it: |
| 32 | +- `getValue` used to retrieve the currently selected value. |
| 33 | +- `setValue` used to set a new value. |
| 34 | + |
| 35 | +## Radio Button |
| 36 | + |
| 37 | +The inner component to compose radio selectors. They will be rendered as radio input elements of HTML transferring the given properties that concerns to them. |
| 38 | + |
| 39 | +| Name | Type | Default | Description| |
| 40 | +|:-----|:-----|:-----|:-----| |
| 41 | +| `checked` | `Boolean` | `false` | If true, the input element will be selected by default. Transferred from the parent. | |
| 42 | +| `className` | `String` | `''` | Set a class to give custom styles to the radio button.| |
| 43 | +| `disabled` | `Boolean` | `false` | If true, the item will be displayed as disabled.| |
| 44 | +| `name` | `String` | | Name for the input element. | |
| 45 | +| `onBlur` | `Function` | | Callback function that will be invoked when the input is blurred. | |
| 46 | +| `onChange` | `Function` | | Callback function that will be invoked when the value changes. | |
| 47 | +| `onFocus` | `Function` | | Callback function that will be invoked when the input is focused. | |
| 48 | +| `value` | `Any` | | Value for the radio button. | |
0 commit comments