Skip to content

Commit 0df2d8d

Browse files
committed
Add docs for radio buttons
1 parent b5b7b13 commit 0df2d8d

File tree

3 files changed

+62
-3
lines changed

3 files changed

+62
-3
lines changed

components/radio/readme.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,48 @@
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. |

docs/app/components/layout/main/modules/components.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import ListExample1 from './examples/list_example_1.txt';
3838
import MenuExample1 from './examples/menu_example_1.txt';
3939
import NavigationExample1 from './examples/navigation_example_1.txt';
4040
import ProgressBarExample1 from './examples/progressbar_example_1.txt';
41+
import RadioExample1 from './examples/radio_example_1.txt';
4142
import TimePickerTest from './examples/timepicker_example_1.txt';
4243

4344
export default {
@@ -137,9 +138,10 @@ export default {
137138
examples: [ProgressBarExample1]
138139
},
139140
radio_group: {
140-
name: 'Radio Group',
141+
name: 'Radio Buttons',
141142
docs: RadioGroup,
142-
path: '/components/radio_group'
143+
path: '/components/radio_group',
144+
examples: [RadioExample1]
143145
},
144146
slider: {
145147
name: 'Slider',
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const RadioTest = () => (
2+
<RadioGroup name='comic' value='vvendetta'>
3+
<RadioButton label='The Walking Dead' value='thewalkingdead'/>
4+
<RadioButton label='From Hell' value='fromhell' disabled/>
5+
<RadioButton label='V for a Vendetta' value='vvendetta'/>
6+
<RadioButton label='Watchmen' value='watchmen'/>
7+
</RadioGroup>
8+
);
9+
10+
return <RadioTest />;

0 commit comments

Comments
 (0)