RadioGroup Radio group
Select one value from option data or slotted radio items.
Import
Use <hui-radio-group> with uni-app easycom. Import public types from @nscode/handy-uni. For ordinary Vue 3, install the preview plugin from @nscode/handy-uni/web and register its components.
Examples
Interact with the controls to see values and event results on the page.
vue
<template>
<view>
<hui-radio-group
v-model="value"
:options="options"
@update:model-value="event0"
@change="event1"
/>
<text>{{ value }}</text>
<hui-radio-group type="button" default-value="a" :options="options" /><hui-radio-group
direction="vertical"
default-value="b"
:options="options"
/>
<text>{{ lastEvent }}</text>
</view>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const lastEvent = ref('No event yet')
const describe = (value: unknown) => {
try {
return JSON.stringify(value) ?? String(value)
} catch {
return String(value)
}
}
const value = ref<string | number | boolean | null>('a')
const options = [
{ label: '选项 A / Option A', value: 'a' },
{ label: '选项 B / Option B', value: 'b' },
{ label: '禁用 / Disabled', value: 'c', disabled: true }
]
const event0 = (arg0: unknown) => {
lastEvent.value = 'update:modelValue' + ': ' + [describe(arg0)].join(', ')
}
const event1 = (arg0: unknown, arg1: unknown) => {
lastEvent.value = 'change' + ': ' + [describe(arg0), describe(arg1)].join(', ')
}
</script>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
modelValue | ChoiceValue | null | undefined | Controlled value; undefined means omitted. |
defaultValue | ChoiceValue | null | null | Initial uncontrolled value; ignored in controlled mode. |
options | Record<string, unknown>[] | — | Option data; takes precedence over the default slot. |
props | { label?: string | undefined; value?: string | undefined; disabled?: string | undefined; } | — | Data field-name mapping. |
direction | "vertical" | "horizontal" | 'horizontal' | Layout direction. |
type | "default" | "button" | 'default' | Semantic type or input mode; see the type definition. |
disabled | boolean | false | Disable interaction. |
readonly | boolean | undefined | Read-only presentation without value changes. |
size | ComponentSize | — | Component size; inherits configuration when omitted. |
shape | "round" | "check" | — | Selection indicator shape. |
iconPosition | "left" | "right" | — | Icon position relative to the label. |
Root attributes: common props. A Boolean default of undefined supports inheritance; explicit false overrides it. Other Boolean props default to false unless listed otherwise.
Events
| Event | Parameters | Description |
|---|---|---|
update:modelValue | (value: ChoiceValue) | Request a controlled value update. |
change | (value: ChoiceValue, ctx: { option?: Record<string, unknown> }) | Emitted after the value changes. |
Slots
| Slot | Parameters | Description |
|---|---|---|
option | { option, checked, disabled } | Custom option region; replaces its fallback content. |
default | — | Main content. |
Methods
None.
Types
RadioGroupProps、RadioGroupEmits are available from @nscode/handy-uni.
Platform notes
| Behavior | uni-app H5 | WeChat Mini Program | App-vue | Ordinary Vue 3 Web (preview) |
|---|---|---|---|---|
| Basic interaction | Supported; device checks pending | Supported; device checks pending | Supported; device checks pending | Supported by the web platform adapter |
Follow the smoke checklist. Device evidence is tracked separately; unit tests do not establish device acceptance.