Skip to content
🌏 Translated with the assistance of DeepSeek and ChatGPT

Radio

This component is called Radio...

Basic Usage

Radio has two style variants: normal mode ('normal', default) and retro mode (retro). The retro mode style is a tribute to early game UI.

Radio enters controlled mode when modelValue is passed. When not passed or undefined, it's in uncontrolled mode, where you can pass the defaultValue property as the default value.

Hide source code

Disabled, Read-only State

For Radio, readonly sets the read-only state and disabled sets the disabled state. In both cases, the internal <input> will be set to disabled, with almost only style differences between them.

Hide source code

Radio Group

You can combine RadioGroup and Radio to form a radio group.

RadioGroup's value is the value of the selected Radio component.

Similarly, RadioGroup enters controlled mode when modelValue is passed. When not passed or undefined, it's in uncontrolled mode, where you can pass the defaultValue property as the default value.

Retro Style

Readonly

Disabled

Hide source code

Vertical Arrangement

RadioGroup's direction property is used to set the arrangement direction of child radio buttons.



Hide source code

Radio Sizes

Both Radio and RadioGroup have a size property that can be used to set the size of radio buttons.

Single Radio

Group

Hide source code

Options Property

RadioGroup's options property is used to directly pass in options, which can be used for quick creation of simple radio groups.

Hide source code

API

RadioProps

AttributeTypeOptionalDefaultDescriptionVersion
modelValueboolean | nullTrueThe value of the Radio component (controlled mode).0.0.3
defaultValueboolean | nullTrueThe default value of the Radio component (uncontrolled mode).0.0.3
variant'normal' | 'retro'True'normal'The style variant of the radio button.0.0.3
disabledbooleanTruefalseDisabled state.0.0.3
readonlybooleanTruefalseRead-only state.0.0.3
labelstringTrueThe text of the radio button.0.0.3
valueanyTrueThe native value attribute of the radio button.0.0.3
size'medium' | 'large' | 'small'True'medium'Size of the radio button.0.0.3
pollSizeChangebooleanTruefalseEnables polling for component size changes. This may impact performance.0.1.0

RadioEvents

EventParameterDescriptionVersion
update:modelValuevalue: booleanCallback for updating modelValue.0.0.3
inputvalue: boolean, event: InputEventCallback when the radio button is selected.0.0.3
changevalue: boolean, event: EventCallback when the radio button's selection state changes.0.0.3
focusevent: FocusEventCallback when the radio button receives focus.0.0.3
blurevent: FocusEventCallback when the radio button loses focus.0.0.3

RadioGroupProps

AttributeTypeOptionalDefaultDescriptionVersion
modelValueanyTrueThe value of the RadioGroup component (controlled mode).0.0.3
defaultValueanyTrueThe default value of the RadioGroup component (uncontrolled mode).0.0.3
variant'normal' | 'retro'TrueThe style variant for descendant Radio components, which takes precedence over the variant of individual Radio components if set.0.0.3
disabledbooleanTruefalseDisabled state.0.0.3
readonlybooleanTruefalseRead-only state.0.0.3
direction'horizontal' | 'vertical'True'horizontal'The arrangement direction of child radio buttons.0.0.3
options(RadioGroupOption | string)[]TrueOptions for the radio group.0.0.3
size'medium' | 'large' | 'small'TrueSize for descendant Radio components. When set, it overrides the size prop on those components.0.0.3
pollSizeChangebooleanTruefalseEnables polling for component size changes. This also affects the property of the same name in Radio sub-components.0.1.0

RadioGroupSlots

SlotParameterDescriptionVersion
defaultChild radio button components.0.0.3

RadioGroupEvents

EventParameterDescriptionVersion
update:modelValuevalue: anyCallback for updating modelValue.0.0.3
changevalue: anyCallback when the selection in the radio group changes.0.0.3

Option

ts
export interface Option<T = any> {
	value: T
	label: string
}

RadioGroupOption

ts
export interface RadioGroupOption<T = any> extends Option<T> {
	disabled?: boolean
	key?: string | number | symbol
}