VisorVisor
ComponentsForm

Radio Group

A set of mutually exclusive radio options. Built on Radix UI.

Options

Disabled

Card variant

variant="card" draws each item as a card with a leading icon, a title and a one-line description. The chosen card is a lifted fill with a light inset edge and a check mark, so selection is never carried by colour alone. A disabled item stays in place and stays readable, is skipped by the arrow keys, and says why when you pass aria-describedby.

Public needs a verified booking.

Item propPurpose
iconLeading icon or swatch; decorative and hidden from assistive tech
titleThe option's name; it is the item's accessible name
descriptionOne line saying what the option means; it describes the item
aria-describedbyAn id saying why an item is disabled; announced after the description

The resting edge reads the shared --control-edge-* tokens, so --control-edge-width: 0 turns it off; focus and invalid keep drawing at --control-state-edge-width. Per-component overrides: --radio-card-bg, --radio-card-selected-bg, --radio-card-selected-border, --radio-card-border, --radio-card-radius, --radio-card-icon-size.

Set indicator="dot" on the group to draw a radio ring on every card and a dot inside the chosen one, instead of the default check in a filled disc (indicator="check"). The ring and dot read --radio-card-ring (unselected ring), --radio-card-ring-selected and --radio-card-dot. A theme sets them from its yaml: components.radio-card.ring, ring-selected and dot, each a value or { light, dark }.

Stepped variant

variant="stepped" draws one row of equal tiles in a well, each an icon over a label of up to two lines, for a few ordered levels. Pass icon and title on each item, as for the card variant. The chosen tile takes a 12% key fill, a 35% key hairline and a lit top edge; its icon turns the key colour and its label full ink. Arrow keys move the choice and skip a disabled tile, which drops to 35% opacity. size="compact" sets the labels at 10px instead of 11px.

Beside Reach Rings, the chosen level's index is the rings' value:

Theme keys under components.radio-step: key (the chosen tile's tint, hairline and icon, and the focus ring), well, well-radius (the tiles take it minus the well padding, so corners stay concentric), ink, icon-size, selected-bg and selected-border, each also a --radio-step-* property. Unbound, the well is the page nudged 12% toward the ink; a dark app that wants it darker than its plane binds --radio-step-well, for example rgb(0 0 0 / 0.65).

Installation

npx visor add radio-group

This copies two files into your project:

  • components/ui/radio-group/radio-group.tsx — the component
  • components/ui/radio-group/radio-group.module.css — the styles

Usage

import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group/radio-group';
import { Label } from '@/components/ui/label/label';

<RadioGroup defaultValue="a">
  <div style={{ display: 'flex', alignItems: 'center', gap: '0.5rem' }}>
    <RadioGroupItem value="a" id="a" />
    <Label htmlFor="a">Option A</Label>
  </div>
  <div style={{ display: 'flex', alignItems: 'center', gap: '0.5rem' }}>
    <RadioGroupItem value="b" id="b" />
    <Label htmlFor="b">Option B</Label>
  </div>
</RadioGroup>

API Reference

RadioGroupProps

PropTypeDefaultDescription
valuestring—Controlled value of the selected radio item.
defaultValuestring—Default selected value for uncontrolled usage.
onValueChange(value: string) => void—Callback when the selected value changes.
disabledbooleanfalseDisables all radio items in the group.
variant'default' | 'card' | 'stepped''default'default draws a dot beside a label; card draws each item as a card with icon, title and description; stepped draws one row of equal tiles in a well, each an icon over a label.
size'default' | 'compact''default'Stepped variant only. compact sets the tile labels at 10px instead of 11px.

Sub-components

ComponentElementPurpose
RadioGroup<div>Root container with role="radiogroup" managing selection state
RadioGroupItem<button>Individual radio option with role="radio" and circle indicator (or, in the card variant, icon, title, description and check mark)

Accessibility

  • Built on @radix-ui/react-radio-group with full WAI-ARIA radio group semantics
  • RadioGroup renders with role="radiogroup"; each RadioGroupItem renders with role="radio"
  • Wrap the group in a <Fieldset> with a <FieldsetLegend> to give the group an accessible name
  • Each item should have an associated <Label> via matching htmlFor/id
  • Keyboard: Arrow keys move selection within the group and skip disabled items; Tab moves focus to/from the group
  • Stepped variant: the title names the item (aria-labelledby); the icon is hidden from assistive tech, and focus draws a ring in the key colour
  • Card variant: the title names the item (aria-labelledby), the description and any aria-describedby id describe it, and the chosen card carries a check mark as well as a fill