Radio
Introduction
The radio component is used for users to select one option from multiple choices. There are two tags for implementing radio buttons: <MYRadio /> or <MYRadio></MYRadio><MYRadio-group> or <MYRadio-group></MYRadio-group> for radio button groups
Basic Usage
Single Radio Button
Use modelValue to bind the value of the radio button.
Code Demo
展开代码
Radio Button Group
Use radioGroup to group radio buttons together.
Code Demo
展开代码
Disabled State
Individual Disabled
Disable specific radio buttons.
Code Demo
展开代码
Group Disabled
Disable the entire radio button group.
Code Demo
展开代码
Layout Direction
Vertical Layout
Use direction="vertical" to achieve vertical layout.
Code Demo
展开代码
Button Style
Radio Button Style
Use MYRadioButton to implement button-style radio buttons.
Code Demo
展开代码
Button Size
Button-style radio buttons also support size control.
Code Demo
展开代码
API Reference
MYRadioGroup Props
| Parameter | Description | Type | Options | Default |
|---|---|---|---|---|
| modelValue | Bound value | string | number | boolean | — | '' |
| direction | Layout direction | string | horizontal/vertical | horizontal |
| disabled | Whether disabled | boolean | — | false |
| textColor | Text color | string | Supports hex colors or color names | #fff |
MYRadio Props
| Parameter | Description | Type | Options | Default |
|---|---|---|---|---|
| modelValue | Bound value | string | number | — | '' |
| value | Option value | string | number | — | '' |
| name | Native name attribute | string | — | '' |
| disabled | Whether disabled | boolean | — | false |
MYRadioButton Props
| Parameter | Description | Type | Options | Default |
|---|---|---|---|---|
| modelValue | Bound value | string | number | — | '' |
| value | Option value | string | number | — | '' |
| label | Display text | string | — | '' |
| name | Native name attribute | string | — | '' |
| size | Size | string | small/default/large | default |
| disabled | Whether disabled | boolean | — | false |
Type Definitions
typescript
interface RadioGroupProps {
modelValue?: string | number | boolean;
disabled?: boolean;
direction?: 'horizontal' | 'vertical';
textColor?: string;
}
interface RadioProps {
modelValue?: string | number;
value?: string | number;
name?: string;
disabled?: boolean;
}
interface RadioButtonProps {
modelValue?: string | number;
value?: string | number;
label?: string;
name?: string;
size?: 'small' | 'default' | 'large';
disabled?: boolean;
}