Skip to content

Radio - Vant 4

Radio

Intro

Single selection among multiple options.

Install

Register component globally via app.use, refer to Component Registration for more registration ways.

js
import { createApp } from'vue'; import { RadioGroup, Radio } from'vant'; const app = createApp(); app.use(Radio); app.use(RadioGroup);

Usage

Basic Usage

Use v-model to bind the name of checked radio.

html
js
import { ref } from'vue'; exportdefault { setup() { const checked = ref('1'); return { checked }; }, };

Horizontal

html

Disabled

html

Custom Shape

html

Custom Color

html

Custom Icon Size

html

Custom Icon

Use icon slot to custom icon

html
js
import { ref } from'vue'; exportdefault { setup() { const checked = ref('1'); return { checked, activeIcon: 'https://fastly.jsdelivr.net/npm/@vant/assets/user-active.png', inactiveIcon: 'https://fastly.jsdelivr.net/npm/@vant/assets/user-inactive.png', }; }, };

Left Label

Set label-position prop to 'left' to adjust the label position to the left of the Radio.

html

Disable Label Click

html

Inside a Cell

html

Types

The component exports the following type definitions:

ts
importtype { RadioProps, RadioShape, RadioGroupProps, RadioLabelPosition, RadioGroupDirection, } from'vant';

API

Radio Props

AttributeDescriptionTypeDefault
nameRadio name, usually a unique string or numberany-
shapeCan be set to square``dotstringround
disabledWhether to disable radiobooleanfalse
label-disabledWhether to disable label clickbooleanfalse
label-positionCan be set to leftstringright
icon-sizeIcon size*numberstring*
checked-colorChecked colorstring#1989fa

RadioGroup Props

AttributeDescriptionTypeDefault
v-modelName of checked radioany-
disabledDisable all radiosbooleanfalse
directionDirection, can be set to horizontalstringvertical
icon-sizeIcon size of all radios*numberstring*
checked-colorChecked color of all radiosstring#1989fa

| shape v4.6.3 | Can be set to square``dot | string | round |

Radio Events

EventDescriptionParameters
clickEmitted when radio is clickedevent: MouseEvent

RadioGroup Events

EventDescriptionParameters
changeEmitted when value changedname: string

Radio Slots

NameDescriptionSlotProps
defaultCustom label{ checked: boolean, disabled: boolean }
iconCustom icon{ checked: boolean, disabled: boolean }

Theming

CSS Variables

The component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.

NameDefault ValueDescription
--van-radio-size20px-
--van-radio-dot-size8pxThe distance between the dot and the border
--van-radio-border-colorvar(--van-gray-5)-
--van-radio-durationvar(--van-duration-fast)-
--van-radio-label-marginvar(--van-padding-xs)-
--van-radio-label-colorvar(--van-text-color)-
--van-radio-checked-icon-colorvar(--van-primary-color)-
--van-radio-disabled-icon-colorvar(--van-gray-5)-
--van-radio-disabled-label-colorvar(--van-text-color-3)-
--van-radio-disabled-backgroundvar(--van-border-color)-

Enterprise-level mobile solution based on Vant