Radio group
One choice from a short list shown at once.
In Dense data
See it live
npm run storybookWhen to use it
In Dense data: Picks one of two or three options, all visible at once.
- Use it when: Two to about five options where the answer is one of them.
- Not when: Many options (select), many answers (checkboxes), or a setting that applies at once (switch).
Instead:
Words
- Lead with the object, then the state: "Alert 2041 contained."
- Use numbers, not words for numbers.
- One verb per button. No "please", no exclamation marks.
- Use: Investigate, Filter, Assign, Escalated, Resolved. Avoid: Oops, Awesome, Please, Simply.
The labels components use, from the voice tokens:
content.action.commit: Savecontent.action.cancel: Cancelcontent.action.destroy: Deletecontent.action.retry: Retrycontent.action.empty-action: Change filters
See Voice and tone for the whole voice.
Accessibility and keyboard
| Keyboard | What happens | Not |
|---|---|---|
| undefined | Arrow keys move the choice; Tab leaves the group. | undefined |
Test before you ship:
- The options are a group with a question as its name. undefined
Use it in code
npx open-ds add radio-group
The component reads only component keys and semantic tokens, so it follows the brand and mode on <html>.
Tokens it reads
Radio group reads 14 tokens of its own, each an alias of a semantic token. Each row is one part: its own token, the semantic it aliases, and the value it ends at. Change a semantic and every component that reads it follows; override one of Radio group's tokens to change Radio group alone.
Dense data decides what changes when you switch theme. Here a switch changes colors only, so the marked rows differ between light and dark; everything else holds steady.
| Part | Its token and the semantic it aliases | Value |
|---|---|---|
| Radio group | ||
| Gap | component.radio-group.gapcomponent-spacing-map.x3var(--radio-group-gap) | space.12:0.75rem |
| Icon Changes with theme | component.radio-group.iconcolor.action.primaryvar(--radio-group-icon) | Lightviolet.light.600:#4B3FD9Darkviolet.dark.600:#A9A3F6 |
| Item | ||
| Icon size | component.radio-group.item.icon-sizesize.iconvar(--radio-group-item-icon-size) | size.16:1rem |
| Corner | component.radio-group.item.radiusradius.roundvar(--radio-group-item-radius) | radius.full:9999px |
| Border Changes with theme | component.radio-group.item.bordercolor.border.strongvar(--radio-group-item-border) | Lightslate.light.500:#6B7585Darkslate.dark.400:#969FAD |
| Text Changes with theme | component.radio-group.item.labelcolor.action.primaryvar(--radio-group-item-label) | Lightviolet.light.600:#4B3FD9Darkviolet.dark.600:#A9A3F6 |
| Shadow | component.radio-group.item.shadowelevation.cardvar(--radio-group-item-shadow) | shadow.none |
| Border focus Changes with theme on focus | component.radio-group.item.border-focuscolor.border.focusvar(--radio-group-item-border-focus) | Lightviolet.light.600:#4B3FD9Darkviolet.dark.600:#A9A3F6 |
| Disabled opacity disabled when disabled | component.radio-group.item.disabled-opacity-disabledopacity.disabledvar(--radio-group-item-disabled-opacity-disabled) | opacity.40:0.4 |
| Border invalid Changes with theme when invalid | component.radio-group.item.border-invalidcolor.status.dangervar(--radio-group-item-border-invalid) | Lightred.light.600:#C42B2BDarkred.dark.600:#F28B8B |
| Focus ring invalid Changes with theme when invalid | component.radio-group.item.focus-ring-invalidcolor.status.dangervar(--radio-group-item-focus-ring-invalid) | Lightred.light.600:#C42B2BDarkred.dark.600:#F28B8B |
| Focus on focus | component.radio-group.item.focusborder-width.focusvar(--radio-group-item-focus) | border-width.2:2px |
| Focus ring focus Changes with theme on focus | component.radio-group.item.focus-ring-focuscolor.border.focusvar(--radio-group-item-focus-ring-focus) | Lightviolet.light.600:#4B3FD9Darkviolet.dark.600:#A9A3F6 |
| Focus ring offset focus Changes with theme on focus | component.radio-group.item.focus-ring-offset-focuscolor.surface.canvasvar(--radio-group-item-focus-ring-offset-focus) | Lightslate.light.50:#F7F8FADarkslate.dark.0:#0D1117 |
| From the system | ||
| Edge Changes with theme | color.border.default straight from the system, through --border | Lightslate.light.200 · #DDE2EADarkslate.dark.100 · #262D38 |