Skip to content

Radio group

radio-group

A choice of exactly one option. The selected dot travels between options on a spring, each option carries its own label and optional description, and arrow keys move the selection in the direction the options are laid out.

Install

$npxshadcnadd@forme/radio-group

Adds the component, its registry dependencies, and the token stylesheet you import once.

Usage

import { Radio, RadioGroup } from "@/components/forme/radio-group/radio-group";

<RadioGroup defaultValue="daily" aria-label="Digest frequency">
  <Radio value="daily" label="Daily digest" description="One email each morning." />
  <Radio value="weekly" label="Weekly summary" description="Every Monday." />
</RadioGroup>

When to use

Reach for it

  • Two to five mutually exclusive options that should stay visible, so the choice can be compared rather than recalled from a closed menu.
  • description when the label alone cannot carry the consequence — what happens, when, or which one is recommended.
  • A horizontal group for short labels, by giving RadioGroup a flex-row class; the arrow keys follow the layout either way.

Use something else

  • More than about six options: a Select keeps the page short and the keyboard path obvious.
  • Making one option selected by default when "none" is a real answer — start from undefined, not the first item.

API reference

Read from the source, so it is the API of the file you install. A prop marked * is required.

Radio

One option, with its label.

PropTypeDefaultDescription
labelReactNode—The visible label, rendered beside the control and part of the click target.
descriptionReactNode—Supporting text under the label. Announced as the description rather than as part of the name, so the control is still "Daily digest" and not that plus the sentence explaining it.

Also takes every prop of Base UI Radio.Root.

The other parts

  • RadioGroupTakes ComponentProps<typeof RadioGroupPrimitive>

Accessibility

  • One tab stop per group: the checked option is reachable, arrows move between options and select as they arrive, exactly like a native radio.
  • The label is a real <label> bound to the hidden input, so the text is part of the target and works with a screen reader's form navigation.
  • description is aria-describedby, not folded into the name, so the option is announced as "Daily digest" and then explained.

Motion

  • The spring is the information: one dot moving between options says the value changed, where a second dot appearing would say the control was replaced.
  • Reduced motion keeps the travel but removes the spring, so the dot is in its new place on the next frame.

Responsive behaviour

  • Options stack by default; flex-row with flex-wrap suits short labels and wraps rather than overflowing on narrow screens.
  • A description makes the option taller, so the row aligns to the top of the label block instead of its centre.