Skip to content

React Radio Group

A React radio group in two styles: glass dots whose pip springs out, or rich option cards where the selection glides from card to card.

npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/radio-group.json
Choose a plan

Classic

Each option can carry a description; the legend names the group for screen readers.

Email digest

How often we send a summary of activity.

Files to copy

5 folders · 6 files · 4 packages
From theme/src/
  • components/radio-group/
  • hooks/{use-latest.ts, use-media-query.ts, use-preferences.ts}
  • motion/tokens.ts
  • lib/{cn.ts, form.ts}
  • styles/
shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/radio-group.jsonRegistry item: radio-group. The styles need the Tailwind v4 glass UI setup.
The examples also use
  • components/badge/
  • components/button/
  • components/spinner/
  • components/toast/
  • hooks/{use-direction.ts, use-magnetic.ts}
  • motion/gate.ts
  • lib/{state-light.tsx, warn-once.ts}
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/badge.json https://lokendra-builds.github.io/sheenui/r/button.json https://lokendra-builds.github.io/sheenui/r/toast.json
Packages
pnpm add @base-ui/react clsx motion tailwind-merge

Option cards

Cards take an icon, a description and meta such as a price. The selection tint slides to the chosen card (it jumps with reduced motion). Columns follow the group's own width: pricing-style cards side by side when there's room, compact rows on phones.

Plan

Selected: Pro

Composed cards

Compose RadioCard children for custom content, such as a badge or a delivery estimate.

Delivery

Horizontal, with validation

A required choice in a row (it wraps on small screens). The error is linked to every radio and announced politely when it appears; focus moves to the group so the fix is one key press away.

Size

RadioGroup

PropTypeDefaultDescription
onBlurFocusEventHandler<HTMLElement>NoneCalled when focus leaves the control (not when it moves between the control's own parts).
namestringNoneSubmits the value with a form.
requiredbooleanNoneMarks the group as required for form validation.
disabledbooleanfalseDisables every option of the group.
aria-invalidboolean | "true" | "false"NoneMarks the field as invalid (also set automatically when error is shown).
aria-describedbystringNoneIds of elements that describe the field, merged with the control's own description and error ids.
itemsRadioItem[]NoneThe options. Leave out to compose <Radio> or <RadioCard> children instead.
childrenReactNodeNoneRadio or RadioCard options, when you do not pass items.
variant"card" | "classic""classic""classic" dots or rich "card" options (used for items; also sets the layout for children).
valuestring | nullNoneSets the chosen value when controlled. null means nothing chosen.
defaultValuestring | nullNoneSets the starting value when uncontrolled.
onValueChange((value: string) => void)NoneCalled with the chosen option's value.
labelReactNodeNoneVisible group label (a legend). Use aria-label when there is none.
descriptionReactNodeNoneShows helper text under the label.
errorReactNodeNoneError message; marks every radio invalid and is announced politely when it appears.
orientation"horizontal" | "vertical""vertical"Classic variant: stack the options or lay them out in a row (wraps on small screens).
columns2 | 1 | 3 | 42Card variant: columns once the group is wide enough (always one column when narrow).
cardLayoutRadioCardLayoutNoneCard variant: "row" (side by side), "stack" (pricing-card style), or "auto": stacked once a 3- or 4-column group shows several columns, rows otherwise (e.g. one column on phones).
formstringNoneId of a form outside of which the group is rendered.
readOnlybooleanNoneShow the choice but do not allow changes.
aria-labelstringNoneAccessible name of the group when there is no visible label.
aria-labelledbystringNoneId of an element that names the group.
classNamestringNoneClass for the outer wrapper (label + options + messages).
listClassNamestringNoneClass for the element that lays out the options (list or grid).

Radio / RadioCard

PropTypeDefaultDescription
value (required)stringNoneSets the value this option stands for.
label (required)ReactNodeNoneSets the option's visible text and accessible name.
descriptionReactNodeNoneSecond line under the label (linked to the radio as its description).
disabledbooleanNoneMakes this radio unselectable: it is dimmed and skipped by arrow-key navigation and the tab order.
classNamestringNoneAdds extra classes to the option row (a <label>).
iconReactNodeNoneIcon or illustration at the start of the card.
metaReactNodeNoneTrailing content such as a price or a badge. Read with the label ("Pro, $12/mo").
childrenReactNodeNoneExtra content under the description (feature list, preview). Read as part of the description.
layoutRadioCardLayout"row""row": icon, label and meta side by side, description underneath. "stack": icon and dot on top, text below, meta pinned to the bottom (pricing-card style). "auto" (the group's default): stack once a 3- or 4-column group shows several columns, row otherwise.

Keyboard

KeysAction
Tab/Shift + TabEnter or leave the group once, landing on the chosen option (or the first).
Arrow keysMove the choice and select it.
SpaceSelect the focused option.

Accessibility

  • role="radiogroup" named by label; each radio is linked to its label and description. error is announced politely and linked to the group.
  • RadioCard shows the focus ring on the whole card although the dot holds focus.
  • The unchecked ring keeps 3:1 contrast; the touch hit area is 44 px.

When to use the radio group

  • Use it as a radio card group for a pricing step where the user must pick exactly one plan, with variant="card" showing an icon, a description and a price in meta for each option.
  • Use it for a checkout shipping choice such as Standard or Express, where each option needs a second line of text that a plain dropdown could not show next to the label.
  • Use it for a short survey answer or a notification preference, with the classic variant giving a compact dot per option and a legend from the label prop.
  • Skip it when the list is long or the choices are many; Select is better, Checkbox suits many-of-many answers, and SegmentedControl suits a few view modes rather than form answers.
  • Pair it with Field-style helper text through description and error props, Badge in the meta slot for labels like Popular, and Button to submit the chosen value after name posts it.

Frequently asked questions

67 components pages in all: browse them on All components.

By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .