Forms
RadioGroup
One choice out of two to five visible options, as a fieldset with a legend.
- Experimental
- Keyboard tested
- Screen reader not tested yet
Playground
Change the props. The controls come from the documented props.
<RadioGroup
label="Start"
name="playground-start"
options={[
{ value: "now", label: "Now" },
{ value: "quarter", label: "Next quarter" },
{ value: "open", label: "Not decided" },
]}
/>States
Every variant in every state, side by side. Hover, pressed and focus are shown statically; the default state is interactive.
Usage
When to use
Use a radio group for one choice out of two to five options that people should see and compare side by side.
When not to use
- For six or more options: use Select.
- For one yes/no decision: use Checkbox.
How it works
A fieldset with a legend names the group; the native radios share one name. Tab enters and leaves the group, arrow keys move between options. Each option can have a hint. With required, Form reports a group without a choice.
Content guidelines
The legend asks the question, the options answer it in parallel form. Order options the way people think about them, not alphabetically. Use hints only where the difference between options isn't obvious from the label.
Do and don’t
Do
- Order the options the way people think about them, not alphabetically.
Don’t
- Don't use it for more than five options; use Select.
Anatomy
The parts of the component and what each one does, as in the playground above.
- legendThe question, 14px medium.
- option24px circle; checked shows an ink ring with a white centre.
- labelBody text, with an optional one-line hint.
- error-messageOne message for the whole group.
Examples
Type-checked, and the same code goes into the AI manifest. Import: import { RadioGroup } from "@/ds";
Project type
Props
Checked against the component's TypeScript type on every build.
| Name | Type | Default | Description |
|---|---|---|---|
| label (required) | string | – | The question, rendered as the legend. |
| name (required) | string | – | Form field name. |
| options (required) | RadioOption[] | – | value, label and an optional hint per option. |
| defaultValue | string | – | Option selected first. Leave empty when there is no sensible default. |
| required | boolean | false | A choice is needed to submit. |
| optional | boolean | false | Adds “(optional)” to the legend. |
| hint | string | – | Help text under the legend. |
| error | string | – | Error message; overrides native validation. |
| messages | ValidationMessages | – | Texts for native validation. |
| disabled | boolean | false | Disables every option. |
Tokens used
Derived from the utility classes in the component's source. Copy a class with one click.
| Token | Tier | Value | Utility |
|---|---|---|---|
| choice.border | component | #8A8578 | |
| choice.checked | component | #0A0A0B | |
| choice.size | component | 24px | |
| input.bg | component | #FAFAF7 | |
| input.errorRing | component | #C6492E | |
| focus | semantic | #C6492E | |
| spacing.1 | semantic | 4px | |
| spacing.2 | semantic | 8px | |
| spacing.3 | semantic | 12px | |
| state.disabled | semantic | 0.5 | |
| surface.page | semantic | #FAFAF7 | |
| text.primary | semantic | #0A0A0B | |
| text.secondary | semantic | #555555 | |
| type.body.size | semantic | 16px | |
| type.small.size | semantic | 14px | |
| weight.medium | semantic | 500 | |
| weight.regular | semantic | 400 |
Accessibility
What is checked automatically on every build, and what a person has tested. Nothing is marked as tested unless it was.
| Check | How | Status |
|---|---|---|
| axe-core rules | Automated on every npm run check, at desktop and mobile width | Runs on every build |
| Keyboard | Automated Playwright test (scripts/keyboard.mjs) | Tested |
| Screen reader | Manual | Not tested yet |
Keyboard
| Key | Action |
|---|---|
| Tab | Moves into the group, to the selected option or the first one. |
| Arrow keys | Select the previous or next option. |
Semantics and focus
- <fieldset> and <legend> name the group; native radios share one name.
- Tab enters and leaves the group; arrow keys move between options.
Contrast
| Pairing | Ratio (x:1) | Minimum | Status |
|---|---|---|---|
| text.primary on surface.page | 18.92 | 4.5 | Pass |
| text.secondary on surface.page | 7.13 | 4.5 | Pass |
| accent.default on surface.page | 4.57 | 4.5 | Pass |
| border.control on surface.page | 3.52 | 3.0 | Pass |
| focus on surface.page | 4.57 | 3.0 | Pass |
| border.control on surface.inverse | 5.38 | 3.0 | Pass |
| accent.default on surface.inverse | 4.14 | 3.0 | Pass |
| surface.inverse on accent.default | 4.14 | 3.0 | Pass |