Skip to content

RadioGroup

import { Radio, RadioGroup } from 'yarcl';
Plan

Value: pro

Billing

Choose how often to pay.

<RadioGroup label="Plan" value={plan} onValueChange={setPlan} orientation="horizontal">
<Radio value="free">Free</Radio>
<Radio value="pro">Pro</Radio>
<Radio value="team">Team</Radio>
</RadioGroup>

RadioGroup renders a <fieldset> with a <legend>, gives the radios a shared name, and tracks the selected value. Radios inside don’t need name or checked. Like Field, it takes description and error.

Native radio keyboard behavior applies: Tab moves into the group, arrow keys change the selection.

PropTypeDefaultDescription
children requiredReactNodeRadios, each with a value.
label requiredReactNodeVisible group label, rendered as the <legend>.
colorColorconfigColor of every radio, from the colors config.
defaultValuestring | nullnullInitially selected value when uncontrolled.
descriptionReactNodeHelper text shown below the options.
errorReactNodeError message. Marks the options invalid and styles them with defaults.errorColor.
namestringForm field name shared by the radios. Generated when omitted.
onValueChange(value: string) => voidCalled with the selected radio's value.
orientation'horizontal' | 'vertical''vertical'Lays the radios out in a row or a column.
sizeSizeconfigSize of every radio, from the sizes config.
valuestring | nullControlled selected value.

Accepts every native <input> attribute except type, color and size.

PropTypeDefaultDescription
childrenReactNodeLabel shown next to the radio.
colorColorconfigconfig.defaults.colorColor of the selected radio, from the colors config. Inherited from a RadioGroup.
sizeSizeconfigconfig.defaults.sizeRadio size, from the sizes config (uses the size's iconSize). Inherited from a RadioGroup.
valuestringValue reported to the RadioGroup and submitted with forms.