JGuang

Radio

Radio · Ant Design Mobile

Preview
npm install antd-mobile@5.43.0

Radio

Make a single selection in a set of options.

Install

npm install antd-mobile@5.43.0

antd-mobile is for mobile web, not React Native or Mini Programs. React 19 projects must register createRoot with unstableSetRender at the entry, or imperative APIs such as Toast and Dialog cannot render. Switch dark mode with <html data-prefers-color-scheme="dark">.

Examples come from the official Ant Design Mobile repository (MIT) at the commit published as npm 5.43.0. Presentation helpers such as DemoBlock are JGuang rewrites, not antd-mobile APIs.

Make a single selection in a set of options.

When to Use

All options of the radio button are visible by default, which is convenient for users to select in the comparison, so the options should not be too many.

Demos

Radio

Props

type RadioValue = string | number

Radio

NameDescriptionTypeDefault
blockWhether to render as a block-level elementbooleanfalse
checkedTo specify whether it is currently selectedbooleanfalse
defaultCheckedTo specify whether it is currently selected by defaultbooleanfalse
disabledDisabled statebooleanfalse
iconCustomized icon icon(checked: boolean) => React.ReactNode-
idThe id of the input element, often used in conjunction with the labelstring-
onChangeCallback function when checked is changed(val: boolean) => void-
onClickRadio's click event(event: React.MouseEvent<HTMLLabelElement, MouseEvent>) => void-
valueValue is carrying identification, used in Group modeRadioValue-

Radio.Group

NameDescriptionTypeDefault
defaultValueOption selected by defaultRadioValue | nullnull
disabledDisabled for the whole groupbooleanfalse
onChangeCallback function when the value is changed(value: RadioValue) => void-
valueSpecified selected optionRadioValue | null-

CSS Variables

Radio

NameDescriptionDefault
--font-sizeFont size of the description label.17px
--gapThe gap between the check icon and the description label.8px
--icon-sizeSize of the check icon.22px