Skip to content

Radio

YhRadio, YhRadioGroup, and YhRadioButton are used to pick a single value from a set of choices. They support standalone usage, grouped usage, option list rendering, button style mode, and token-based theming.

Select a single option from a set of mutually exclusive choices.

Basic Usage

Use YhRadioGroup with multiple YhRadio children for standard single-choice selection.

Basic Usage

Disabled State

You can disable the whole group or a single radio item.

Disable entire group:

Disable individual:

Disabled State

Standalone Usage

YhRadio can also be used without a group by binding v-model directly.

Standalone Usage

With Border

Use border to render bordered radios.

With Border

Different Sizes

size is supported by both standalone radios and group inheritance.

Different Sizes
Inherited Group Size

Render by Options

YhRadioGroup can render radios from the options prop when you do not need custom slot content.

Render by Options

Button Style

Use YhRadioButton for segmented button-like choices.

Button Style

Button Colors

When using radio buttons, fill and text-color from the group control the checked visual state.

Button Colors

Button Disabled and Sizes

Button Disabled
Button Sizes

Use in Nuxt

After installing @yh-ui/nuxt, YhRadio, YhRadioGroup, and YhRadioButton can be used directly in Nuxt 3/4 pages and components. The checked state renders correctly in SSR and continues to work after hydration.

Use in Nuxt

API

Radio Props

PropDescriptionTypeDefault
model-value / v-modelBound value in standalone modeYhRadioValueTypeundefined
valueCurrent radio value. In practice, the change path emits value; omitting it can lead to undefined being emitted even though checked-state comparison falls back to label.YhRadioValueTypeundefined
nameNative name attributestringundefined
labelFallback text when the default slot is not usedstringundefined
sizeRadio size'large' | 'default' | 'small'undefined
disabledDisable the radiobooleanfalse
borderShow bordered stylebooleanfalse
idNative id attributestringundefined
tabindexNative tabindex attributestring | numberundefined
theme-overridesComponent theme override variablesComponentThemeVarsundefined

Radio Events

EventDescriptionParameters
update:modelValueTriggered when the standalone bound value changes(value: YhRadioValueType) => void
changeTriggered when the standalone bound value changes(value: YhRadioValueType) => void

Radio Slots

SlotDescriptionParameters
defaultRadio label content-

Radio Expose

NameDescriptionType
refNative radio input element referenceHTMLInputElement | undefined
focusFocus the radio input() => void
blurBlur the radio input() => void

RadioButton Props

PropDescriptionTypeDefault
model-value / v-modelBound value in standalone modeYhRadioValueTypeundefined
valueCurrent radio button value. If omitted, checked-state and emitted value both fall back to label.YhRadioValueTypeundefined
nameNative name attributestringundefined
labelFallback text when the default slot is not usedstringundefined
sizeRadio button size'large' | 'default' | 'small'undefined
disabledDisable the radio buttonbooleanfalse
idNative id attributestringundefined
tabindexNative tabindex attributestring | numberundefined
theme-overridesComponent theme override variablesComponentThemeVarsundefined

RadioButton Events

EventDescriptionParameters
update:modelValueTriggered when the standalone bound value changes(value: YhRadioValueType) => void
changeTriggered when the standalone bound value changes(value: YhRadioValueType) => void

RadioButton Slots

SlotDescriptionParameters
defaultRadio button label content-

RadioButton Expose

NameDescriptionType
refNative radio input element referenceHTMLInputElement | undefined
focusFocus the radio button input() => void
blurBlur the radio button input() => void

RadioGroup Props

PropDescriptionTypeDefault
model-value / v-modelBound valueYhRadioValueTypeundefined
optionsOptional option list rendered by the groupYhRadioGroupOption[]undefined
sizeGroup size inherited by child radios'large' | 'default' | 'small'undefined
disabledDisable the whole groupbooleanfalse
nameNative name attribute passed to child radiosstringundefined
validate-eventTrigger form validation when the group value changesbooleantrue
text-colorChecked text color in radio button modestringundefined
fillChecked background and border color in radio button modestringundefined
tagWrapper tag or componentstring | Component'div'
theme-overridesComponent theme override variablesComponentThemeVarsundefined

RadioGroup Events

EventDescriptionParameters
update:modelValueTriggered when the group value changes(value: YhRadioValueType) => void
changeTriggered when the group value changes(value: YhRadioValueType) => void

RadioGroup Slots

SlotDescriptionParameters
defaultCustom group content-

When the default slot is empty and options is provided, the group renders YhRadio items from options.

RadioGroup Expose

This component does not expose public instance methods or properties.

Type Exports

TypeDescription
YhRadioPropsRadio props type
YhRadioEmitsRadio emits type
YhRadioSlotsRadio slots type
YhRadioExposeRadio expose type
YhRadioGroupPropsRadio group props type
YhRadioGroupEmitsRadio group emits type
YhRadioGroupOptionRadio group option item type
YhRadioButtonPropsRadio button props type
YhRadioButtonEmitsRadio button emits type
YhRadioButtonExposeRadio button expose type
YhRadioValueTypeShared value type
YhRadioInstanceRadio instance type
YhRadioGroupInstanceRadio group instance type
YhRadioButtonInstanceRadio button instance type

Theme Variables

YhRadio, YhRadioGroup, and YhRadioButton support themeOverrides. YhRadioGroup.themeOverrides is also inherited by child radios through injection.

Radio-related dedicated CSS variables:

VariableDescriptionDefault
--yh-radio-sizeRadio control size14px
--yh-radio-input-borderRadio border colorvar(--yh-border-color)
--yh-radio-checked-bg-colorChecked background colorvar(--yh-color-primary)
--yh-radio-checked-border-colorChecked border colorvar(--yh-color-primary)
--yh-radio-checked-icon-colorChecked icon color tokenvar(--yh-color-primary)
--yh-radio-text-colorLabel text colorvar(--yh-text-color-regular)

Radio button dedicated CSS variables:

VariableDescriptionDefault
--yh-radio-button-font-sizeButton font sizevar(--yh-font-size-base)
--yh-radio-button-text-colorButton text colorvar(--yh-text-color-regular)
--yh-radio-button-bg-colorButton background colorvar(--yh-fill-color-blank)
--yh-radio-button-border-colorButton border colorvar(--yh-border-color)
--yh-radio-button-hover-text-colorHover text colorvar(--yh-color-primary)
--yh-radio-button-checked-bg-colorChecked background colorvar(--yh-color-primary)
--yh-radio-button-checked-border-colorChecked border colorvar(--yh-color-primary)
--yh-radio-button-checked-text-colorChecked text color#ffffff
--yh-radio-button-disabled-bg-colorDisabled background colorvar(--yh-fill-color-light)
--yh-radio-button-disabled-border-colorDisabled border colorvar(--yh-border-color-light)
--yh-radio-button-disabled-text-colorDisabled text colorvar(--yh-text-color-placeholder)

Released under the MIT License.