v0.5.1

Radio Group

Group of mutually exclusive radio options, built on Radix UI.

Installation

npx paubha@latest add radio-group

Usage

import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";

<RadioGroup defaultValue="free" aria-label="Plan">
  <RadioGroupItem value="free" label="Free" />
  <RadioGroupItem value="pro" label="Pro" />
</RadioGroup>

Examples

Disabled

API reference

RadioGroup

PropTypeDefaultDescription
valuestring—Controlled selected value.
defaultValuestring—Uncontrolled initial selected value.
onValueChange(value: string) => void—Called when the selection changes.
disabledboolean—Disables every item in the group.

RadioGroupItem

PropTypeDefaultDescription
valuestring—This item's value within the group.
labelReactNode—Clickable label, linked to the control via for/id.
disabledboolean—Disables this item only.

Accessibility

Accessibility

  • Role. role="radiogroup", each item role="radio", provided by Radix.

  • Keyboard. Arrow keys move roving focus between items; Space (or a click) selects the focused one. In this Radix version, arrow-key navigation moves focus without auto-selecting, verified directly rather than assumed, since some Radix components (like Tabs) do auto-select on arrow-key move and some don't.

  • Label. Clicking a label selects that item.