1.3.0 • Published 5 months ago
@illa-design/radio v1.3.0
Radio
Radios are used when only one choice may be selected in a series of options.
Installation
yarn add @illa-design/radio
Import component
import { Radio } from "@illa-design/radio"
API
Radio Basic Properties
Props | Desc | Type | Default |
---|---|---|---|
colorScheme | Set background color | "white" | "blackAlpha" | "gray" | "grayBlue" | "red" | "orange" | "yellow" | "green" | "blue" | "cyan" | "purple" | string | "blue" |
value | The value of radio | T | - |
variant | The variant of radio | "button" | "radio" | "radio" |
disabled | Whether the radio is disabled | boolean | - |
checked | Whether the radio is checked (Controlled) | boolean | - |
defaultChecked | Whether the radio is initially selected | boolean | - |
Radio Events
Props | Desc | Type | Default |
---|---|---|---|
onChange | Callback when value changes | (checked: boolean, event: ChangeEvent) => void | - |
RadioGroup Basic Props
Props | Desc | Type | Default |
---|---|---|---|
name | The name of the input field in a radio | string | - |
value | The value to be used in the radio button | T | - |
variant | The variant of radio | "button" | "radio" | "radio" |
colorScheme | Set background color | "white" | "blackAlpha" | "gray" | "grayBlue" | "red" | "orange" | "yellow" | "green" | "blue" | "cyan" | "purple" | string | "blue" |
disabled | Whether the radio is disabled | boolean | - |
defaultValue | To set default value | T | - |
options | Set children options | string[] | number[] | { label: ReactNode; value: any; disabled: boolean }[] | - |
direction | Arrangement direction | "vertical" | "horizontal" | "horizontal" |
spacing | The spacing between the checkbox and its label text | string | number | "24px" |
RadioGroup Events
Props | Desc | Type | Default |
---|---|---|---|
onChange | Callback when value changes | (checked: boolean, event: ChangeEvent) => void | - |
Example
Basic usage
<Radio>Radio</Radio>
<Radio checked disabled>Disabled Radio</Radio>
RadioGroup usage
<RadioGroup defaultValue='a' style={{ marginBottom: 20 }}>
<Radio value='a'>A</Radio>
<Radio value='b'>B</Radio>
<Radio value='c'>C</Radio>
<Radio disabled value='d'>D</Radio>
</RadioGroup>
<br />
<RadioGroup options={['A', 'B', 'C', 'D']} style={{ marginBottom: 20 }} />
<br />
<RadioGroup
options={[
{ label: 'A', value: 'a' },
{ label: 'B', value: 'b' },
{ label: 'C', value: 'c' },
{ label: 'D', value: 'd', disabled: true },
]} />
Set RadioGroup arrangement direction
<RadioGroup direction="vertical" defaultValue="a">
<Radio value="a">A</Radio>
<Radio value="b">B</Radio>
<Radio value="c">C</Radio>
<Radio disabled value="d">
D
</Radio>
</RadioGroup>
1.2.0
5 months ago
1.3.0
5 months ago
1.0.29
10 months ago
1.0.28
10 months ago
1.0.27
11 months ago
1.0.30
9 months ago
1.1.0
8 months ago
1.0.22
1 year ago
1.0.21
1 year ago
1.0.26
12 months ago
1.0.25
12 months ago
1.0.24
1 year ago
1.0.23
1 year ago
1.0.19
1 year ago
1.0.18
1 year ago
1.0.17
1 year ago
1.0.20
1 year ago
1.0.16
1 year ago
1.0.15
1 year ago
1.0.14
1 year ago
1.0.9
1 year ago
1.0.8
1 year ago
1.0.7
1 year ago
1.0.6
2 years ago
1.0.11
1 year ago
1.0.10
1 year ago
1.0.13
1 year ago
1.0.12
1 year ago
1.0.5
2 years ago
1.0.4
2 years ago
1.0.3
2 years ago
1.0.2
2 years ago
1.0.1
2 years ago
1.0.0
2 years ago
0.0.10
2 years ago
0.0.11
2 years ago
0.0.12
2 years ago
0.0.13
2 years ago
0.0.14
2 years ago
0.0.15
2 years ago
0.0.9
2 years ago
0.0.16
2 years ago
0.0.17
2 years ago
0.0.8
2 years ago
0.0.5
2 years ago
0.0.4
2 years ago
0.0.7
2 years ago
0.0.6
2 years ago
0.0.3
2 years ago
0.0.2
2 years ago
0.0.1
2 years ago