Equality
Equality

Radio Group

Group of radio buttons for single selection

View Markdown

Overview

Radio Group lets users pick exactly one option from a small, visible set — permission levels, plans, or any mutually exclusive choice. It’s built on Radix UI Radio Group, so arrow keys move between options, only one can be selected at a time, and the group is exposed correctly to assistive technology.

It is a compound component: a RadioGroup wraps a set of RadioGroupItems. Pair each item with a Label so the choice has a visible, clickable caption. Use it for a handful of always-visible options; when space is tight or the list is long, prefer a Select or Radio Dropdown.

Usage

Import the parts:

import { RadioGroup, RadioGroupItem, Label } from "@eqtylab/equality";

Give each RadioGroupItem an id and point its Label at it with htmlFor, so clicking the label selects the option:

const [value, setValue] = useState("read");

<RadioGroup value={value} onValueChange={setValue}>
  <div className="flex items-center gap-2">
    <RadioGroupItem value="read" id="read" />
    <Label htmlFor="read">Read Only</Label>
  </div>
  <div className="flex items-center gap-2">
    <RadioGroupItem value="write" id="write" />
    <Label htmlFor="write">Read & Write</Label>
  </div>
</RadioGroup>;

Radio Group can be controlled (value + onValueChange) or uncontrolled (defaultValue).

Default

Slots

NameDescription
RadioGroupThe container that manages the selection and keyboard navigation.
RadioGroupItemA single selectable option. Pair each with a Label via id/htmlFor.

Props

Both parts forward their Radix props (and className). The most commonly used are below.

NameApplies toDescriptionTypeRequired
valueRadioGroupThe selected value (controlled).string
defaultValueRadioGroupThe initial selected value (uncontrolled).string
onValueChangeRadioGroupCalled with the new value when the selection changes.(value: string) => void
disabledRadioGroupDisables the entire group.boolean
valueRadioGroupItemThe value this item represents. Required per item.string
idRadioGroupItemLinks the item to its Label via htmlFor.string
disabledRadioGroupItemDisables just this option.boolean