Skip to content

Radio ​

17:06

Description ​

A radio group for single-choice from a set of options. ux-radio-group groups the options, binds the selected value via v-model, and centrally controls shape / size / active-color / disabled; ux-radio is a single option identified by name (or value), with label as the display text.

Compatibility ​

PlatformSupport
App✅ Supported
H5✅ Supported
WeChat Mini Program✅ Supported

Examples ​

Basic Usage ​

Bind the selected value with v-model; only one can be selected within the same group.

View source
vue
<template>
    <ux-radio-group v-model="value">
        <ux-radio label="荔枝" name="荔枝" />
        <ux-radio label="香蕉" name="香蕉" />
        <ux-radio label="橙子" name="橙子" />
    </ux-radio-group>
</template>

<script setup lang="uts">
const value = ref<string>('荔枝');
</script>

Shape ​

shape="circle" is circular, shape="square" is a square (3px small radius).

View source
vue
<template>
    <ux-radio-group v-model="value" shape="square">
        <ux-radio label="荔枝" name="荔枝" />
        <ux-radio label="香蕉" name="香蕉" />
    </ux-radio-group>
</template>

<script setup lang="uts">
const value = ref<string>('荔枝');
</script>

Size ​

Supports small / default / large presets and custom values (in px); with a numeric size, the icon and label scale to 0.6 and 0.8 of it.

View source
vue
<template>
    <ux-radio-group v-model="value" size="large">
        <ux-radio label="荔枝" name="荔枝" />
        <ux-radio label="香蕉" name="香蕉" />
    </ux-radio-group>
</template>

<script setup lang="uts">
const value = ref<string>('荔枝');
</script>

Active Color ​

Set the selected color via active-color, which overrides the group color.

View source
vue
<template>
    <ux-radio-group v-model="value" active-color="#19be6b">
        <ux-radio label="荔枝" name="荔枝" />
        <ux-radio label="香蕉" name="香蕉" />
    </ux-radio-group>
</template>

<script setup lang="uts">
const value = ref<string>('荔枝');
</script>

Disabled ​

Disable a single radio via disabled, or disable all via the group's disabled.

View source
vue
<template>
    <ux-radio-group v-model="value">
        <ux-radio label="荔枝" name="荔枝" :disabled="true" />
        <ux-radio label="香蕉" name="香蕉" />
    </ux-radio-group>
</template>

<script setup lang="uts">
const value = ref<string>('香蕉');
</script>

API ​

Props ​

ux-radio-group ​

PropertyDescriptionTypeDefaultVersion
customStyleCustom root element stylestring | UTSJSONObject--
customClassCustom root element style classstring''-
modelValueBound value; the name/value of the selected radiostring | number''-
disabledWhether to disable all radiosbooleanfalse-
labelDisabledWhether to disable tapping the label to selectbooleanfalse-
shapeShape'circle' | 'square''circle'-
activeColorColor of the selected statestring''-
sizeOverall component sizestring | number''-
iconSizeIcon sizestring | number''-
widthWidth of each radiostring'auto'-
wrapWhether to wrap each radio onto its own linebooleanfalse-

ux-radio ​

PropertyDescriptionTypeDefaultVersion
customStyleCustom root element stylestring | UTSJSONObject--
customClassCustom root element style classstring''-
labelRadio labelstring''-
nameRadio identifierstring | number''-
valueRadio valuestring | number''-
shapeShape: circle – round, square – square'circle' | 'square'--
disabledWhether disabledboolean--
labelDisabledWhether to disable tapping the label to selectboolean--
activeColorColor of the selected state; overrides the group's active-colorstring--
iconSizeIcon size, in pxstring | number--
labelSizeLabel font sizestring | number''-
sizeOverall component sizestring | number--

Events ​

ux-radio-group ​

EventDescriptionParamsVersion
changeFires when any radio's state changes; the callback is the selected valuevalue: string | number-

ux-radio ​

EventDescriptionParamsVersion
changeFires when this radio's state changes; the callback is the selected valuevalue: string | number-

Slots ​

ux-radio-group ​

SlotDescriptionVersion
defaultPlace ux-radio children here-

ux-radio ​

SlotDescriptionVersion
defaultCustom label content (defaults to the label text)-

Notes ​

  • ux-radio must be placed inside ux-radio-group to be grouped and participate in selection; used standalone it does not link with other radios.
  • The selected value is kept by the group's v-model; ux-radio matches it by name (or value when set) — keep their types consistent with the bound value.
  • ux-radio's disabled, label-disabled, size, icon-size, active-color override the same options on the group.
  • When ux-radio's size resolves to a size preset (including numeric), label-size is ignored and the font size comes from that preset.
  • When label-disabled is true, tapping the label does not toggle; only tapping the icon does.