Skip to content

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 ​

ParameterDescriptionTypeOptionsDefault
modelValueBound valuestring | number | boolean—''
directionLayout directionstringhorizontal/verticalhorizontal
disabledWhether disabledboolean—false
textColorText colorstringSupports hex colors or color names#fff

MYRadio Props ​

ParameterDescriptionTypeOptionsDefault
modelValueBound valuestring | number—''
valueOption valuestring | number—''
nameNative name attributestring—''
disabledWhether disabledboolean—false

MYRadioButton Props ​

ParameterDescriptionTypeOptionsDefault
modelValueBound valuestring | number—''
valueOption valuestring | number—''
labelDisplay textstring—''
nameNative name attributestring—''
sizeSizestringsmall/default/largedefault
disabledWhether disabledboolean—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;
}

Released under the MIT License.