Web · Components
Radio
Radio button.
Live example
Preview
Code
Events
- Events appear here when you interact with the preview.
Radio + group: the same group is linked, only one is selected
Delivery
Payment (separate group)
Segment: view and range picker
Selected view: list
Horizontal list and sizes
Optional selection: deselectable
Value: "" (click the selected one again)
Import
Radio button. Only one of the options in the same group can be selected: selecting one clears the others. Built on a real <input type="radio">; works with forms, FormData, arrow keys and screen readers even before JavaScript loads. Usable in server components.
To render options from an array, manage the value in one place and get card or segment looks use RadioGroup; for a form field with label and validation use RadioField. Radio is useful when you need to place options in separate spots on the page.
On touch screens the touch area is enlarged to 44×44 px without changing the look.
Examples
Group where only one of the options can be selected. Options are given with the options array; the value is managed controlled (value) or uncontrolled (defaultValue). For a form field with label and validation use RadioField.
- Real
<input type="radio">elements are used: arrow-key navigation, form submission and form reset work as in the browser. - Three looks: list with round buttons (
default), cards with descriptions (card) and a tab-like strip (segment). SeeRadioVariant. - With
deselectableclicking the selected option again clears it. - On touch screens each option gets at least a 44 px touch area.
Examples
RadioVariant
typeLook of the radio button:
default: round button with a label next to it.card: bordered card, fully clickable; highlighted when selected. For choices with descriptions such as plan, delivery or payment method.segment: the button is hidden and the label looks like a tab piece. Used withRadioGroup, not alone (it gathers the pieces into a strip).
RadioProps
interfaceProps of the Radio component.
Extends: Omit<ComponentProps<"input">, "type" | "size">
| Name | Type | Default | Description |
|---|---|---|---|
group? | string | Option group. Only one of the options with the same group value can be selected; selecting one clears the others. Arrow keys navigate within the group. Submitted in the form as the group name (name); if name is given too, that is used. | |
value? | string | Value submitted in the form if selected. | |
variant? | RadioVariant | CustomVariant<"radio"> | "default" | Look: built-in, or a custom one added with defineAppearance (its classes are added to the option label; laid out like default unless extends is given). If omitted, UIProvider appearance.defaults.radio.variant. See RadioVariant. |
size? | Size | "md" | |
label? | ReactNode | Label next to the button; fully clickable. If given, className is applied to the label itself. | |
description? | ReactNode | Description below the label; screen readers read it with the button. | |
icon? | IconProp | Icon before the label (name or element). Especially useful in the card look. | |
aside? | ReactNode | Extra right-aligned content at the end of the label (e.g. price, "Recommended" badge, delivery time). | |
tooltip? | TooltipProp | Tooltip shown on hover, keyboard focus or long press on touch screens. Opens from the whole label and screen readers read it with the button. See TooltipProp. | |
effect? | EffectProp | Effect or effects. Applied to the whole label in the card and segment looks (e.g. ["lift", "tilt"]), to the round button in the plain look (e.g. "pulse"). If omitted, UIProvider appearance.defaults.radio.effect. See BuiltinEffect. | |
onCheckedChange? | (checked: boolean) => void | Called when the selection changes. A radio button only changes when selected (true). | |
onValueChange? | (value: string) => void | Called with its own value when this option is selected. |
RadioOption
interfaceOption of RadioGroup. If only text is given, it is both value and label.
| Name | Type | Description |
|---|---|---|
value | string | Value submitted in the form; must be unique in the group. |
label? | ReactNode | Visible label. If omitted, value is shown. |
description? | ReactNode | Description below the label. |
icon? | IconProp | Icon before the label (name or element). |
aside? | ReactNode | Extra right-aligned content (e.g. price, badge). |
disabled? | boolean | Disables only this option. |
tooltip? | TooltipProp | Tooltip of the option. See TooltipProp. |
aria-label? | string | Accessible name for icon-only segments that have no label. |
RadioGroupProps
interfaceProps of the RadioGroup component.
Extends: Omit<ComponentProps<"div">, "onChange" | "defaultValue" | "children">
| Name | Type | Default | Description |
|---|---|---|---|
options | readonly (string | RadioOption)[] | Options: text or RadioOption. | |
name? | string | Group name submitted in the form. If omitted, a name is generated (needed for arrow-key navigation); pass it if you read it in the form. | |
value? | string | Selected value (controlled). "" if none is selected. | |
defaultValue? | string | "" | Initially selected value (uncontrolled). |
onValueChange? | (value: string, option: RadioOption | undefined) => void | Called with the new value and option when the selection changes. "" when cleared. | |
variant? | RadioVariant | CustomVariant<"radio"> | "default" | Look: built-in, or a custom one added with defineAppearance (its classes are added to the option label; laid out like default unless extends is given). If omitted, UIProvider appearance.defaults.radio.variant. See RadioVariant. |
effect? | EffectProp | Effect of each option (e.g. ["lift", "glow"] in the card look). See RadioProps.effect. | |
size? | Size | "md" | |
orientation? | "vertical" | "horizontal" | "vertical" | Layout of the options. Horizontal cards spread over as many columns as fit, and stack on narrow screens. segment is always horizontal. |
disabled? | boolean | Disables all options. | |
required? | boolean | The form isn't submitted without a selection. | |
deselectable? | boolean | Clicking the selected option again (or pressing space) clears the selection. Lets optional choices return to "none". | |
form? | string | Id of the form to attach to if the options are outside the form. |