Radio Group
Single-selection group. Use value + onValueChange for controlled behaviour.
Install
Import path
Examples
With Fields
Compose radio items with Field primitives inside a FieldSet.
Enable Touch ID to quickly unlock your device.
Enable Touch ID to quickly unlock your device.
Choice Card
Use FieldLabel to wrap the entire Field for a clickable card-style selection.
Description
Radio group items with a description using the Field component.
Standard spacing for most use cases.
More space between elements.
Minimal spacing for dense layouts.
Disabled
Use the disabled prop on RadioGroupItem to disable individual items.
Fieldset
Use FieldSet and FieldLegend to group radio items with a label and description.
Invalid
Use aria-invalid on RadioGroupItem and data-invalid on Field to show validation errors.
RTL
Right-to-left layout support for languages such as Arabic and Hebrew.
Translations are AI-generated for demonstration and may be imperfect.
تباعد قياسي لمعظم حالات الاستخدام.
مساحة أكبر بين العناصر.
تباعد أدنى للتخطيطات الكثيفة.
Anatomy
How the parts compose. Copy this skeleton and fill in the slots.
import { RadioGroup, RadioGroupItem } from "@codefast/ui/radio-group";
<RadioGroup value={v} onValueChange={setV}>
<RadioGroupItem value="a" id="a" />
<Label htmlFor="a">A</Label>
</RadioGroup>
API reference
Props for each part of the component. All native element props are also forwarded.
RadioGroup
A single-selection group of radio items.
| Prop | Type | Default | Description |
|---|---|---|---|
| value / onValueChange | string / (value: string) => void | — | Controlled selection and its handler. |
| defaultValue | string | — | Initial selection when uncontrolled. |
| disabled | boolean | false | Disables the whole group. |
RadioGroupItem
| Prop | Type | Default | Description |
|---|---|---|---|
| value | string | — | Identifier selected when this item is chosen (required). |
Accessibility
Built to be keyboard-navigable and screen-reader friendly out of the box.
| Key | Function |
|---|---|
| Tab | Moves focus into the group. |
| Arrow+Down | Selects the next item. |
| Arrow+Up | Selects the previous item. |
- Implements the ARIA radiogroup pattern with roving focus.
- Pair each RadioGroupItem with a Label via matching id / htmlFor.
- Arrow keys both move focus and change selection — that’s expected for radios.
Guidelines
Conventions that keep usage consistent across an app.
Do
- Use for 2–7 mutually-exclusive options shown at once.
- Pre-select a sensible default.
Don’t
- Don’t use radios for multi-select — use Checkbox Group.
- Don’t use a radio group when a Select saves space and the list is long.