RadioGroup
Choose one value from a visible set of radio options.
Anatomy#
Usage#
Use RadioGroup for one choice from a small visible set. For a longer or space-constrained collection, use Select. Use CheckboxGroup when several options may be selected together.
Single selection#
items takes strings (used as both value and label) or objects with value, label,
description, and disabled. The selected item is one string: use defaultValue for uncontrolled
state, or pair value with onValueChange for controlled state. onValueChange fires only when the
user selects a different item. Disabled items stay visible but cannot be selected or focused.
variant sets the layout (list, card, or table), and orientation sets the direction.
Keyboard interaction#
The group is one tab stop. The arrow keys that match orientation move focus to the next enabled
item and select it. Home, End, and Shift with an arrow key move focus without selecting.
Space selects the focused item. Navigation wraps unless loop={false}.
Forms#
Set name for native form submission. For schema binding and validation, place the group inside
form.Field from createForm. Standalone Field supplies
labels and messages without binding a form store.
Indicator#
indicatorPosition places the radio mark at the leading or trailing edge, or hides it with
hidden.
Examples#
Choose a billing plan#
Keep one string value for the selected plan. Pair value with onValueChange when the page owns
the choice.
Pick a plan with a locked starter tier#
Disable a legacy option so it stays visible but cannot be selected. Horizontal table layout works
for a short plan comparison.
Bind a deployment environment#
Place the group in form.Field so schema validation owns the required environment value.
Compare plans with the mark at the end#
indicatorPosition="trailing" puts the radio on the trailing edge of a card option. Use hidden when the card
itself is the selected affordance.
API Reference#
Attributes#
data-disableddata-invaliddata-readonlydata-requireddata-checkedProps#
Props for the RadioGroup component. Renders a <div> element by default.