joyent-portal/packages/ui-toolkit/src/form/usage-radio.md

110 lines
2.7 KiB
Markdown
Raw Normal View History

### Radio > Default
```jsx
const React = require('react');
const { default: Radio, RadioList } = require('./radio');
const { default: FormGroup } = require('./group');
const { default: Label } = require('./label');
const { FormLabel } = require('./');
2017-10-12 21:15:51 +03:00
<FormGroup name="who-killed">
2017-12-15 16:53:59 +02:00
<FormLabel style={{ marginBottom: '12px' }}>
Who killed the radio star?
</FormLabel>
<RadioList>
<Radio name="one" value="video">
<Label>Video</Label>
</Radio>
2017-10-12 21:15:51 +03:00
<Radio name="one" value="tv">
<Label>TV</Label>
</Radio>
<Radio name="one" value="netflix">
<Label>Netflix</Label>
</Radio>
</RadioList>
2017-10-12 21:15:51 +03:00
</FormGroup>;
```
2017-12-15 16:53:59 +02:00
### Checkbox > Active/Focused
2017-12-15 16:53:59 +02:00
```jsx
const React = require('react');
const { default: Radio, RadioList } = require('./radio');
const { default: FormGroup } = require('./group');
const { default: Label } = require('./label');
const { FormLabel } = require('./');
<FormGroup name="test">
2017-12-15 16:53:59 +02:00
<FormLabel style={{ marginBottom: '12px' }}>
Who killed the radio star?
</FormLabel>
<RadioList>
<Radio name="one" value="video" checked>
<Label>Video</Label>
</Radio>
<Radio name="one" value="tv">
<Label>TV</Label>
</Radio>
<Radio name="one" value="netflix">
<Label>Netflix</Label>
</Radio>
</RadioList>
2017-12-15 16:53:59 +02:00
</FormGroup>;
```
### Checkbox > Disabled
2017-12-15 16:53:59 +02:00
```jsx
const React = require('react');
const { default: Radio, RadioList } = require('./radio');
const { default: FormGroup } = require('./group');
const { default: Label } = require('./label');
const { FormLabel } = require('./');
<FormGroup name="test">
2017-12-15 16:53:59 +02:00
<FormLabel style={{ marginBottom: '12px' }}>
Who killed the radio star?
</FormLabel>
<RadioList>
<Radio name="one" value="video" disabled>
<Label>Video</Label>
</Radio>
<Radio name="one" value="tv" disabled>
<Label>TV</Label>
</Radio>
<Radio name="one" value="netflix" disabled>
<Label>Netflix</Label>
</Radio>
</RadioList>
2017-12-15 16:53:59 +02:00
</FormGroup>;
```
2017-12-15 16:53:59 +02:00
### Radio input validation
```jsx
const React = require('react');
const { default: Radio, RadioList } = require('./radio');
const { default: FormGroup } = require('./group');
const { default: Label } = require('./label');
const { FormLabel } = require('./');
const { default: FormMeta } = require('./meta');
<FormGroup name="test">
2017-12-15 16:53:59 +02:00
<FormLabel style={{ marginBottom: '12px' }}>
Who killed the radio star?
</FormLabel>
<RadioList>
<Radio name="one" value="video" error>
<Label>Video</Label>
</Radio>
<Radio name="one" value="tv" error>
<Label>TV</Label>
</Radio>
<Radio name="one" value="netflix" error>
<Label>Netflix</Label>
</Radio>
</RadioList>
2017-12-15 16:53:59 +02:00
<FormMeta error>Somethings missing</FormMeta>
</FormGroup>;
```