Radio

Radios allow users to select exactly one option from a set of mutually exclusive choices. Built on top of Radix UI primitives for accessibility.

Basic Usage

import { Radio, RadioGroup } from '@/components'

<RadioGroup defaultValue="option1">
  <Radio value="option1" id="option1" />
  <label htmlFor="option1">Option 1</label>
  <Radio value="option2" id="option2" />
  <label htmlFor="option2">Option 2</label>
</RadioGroup>

States

Radios support two states: unselected and selected.

Unselected

Selected

Unselected

<RadioGroup>
  <Radio value="option" />
</RadioGroup>

Selected

<RadioGroup value="option">
  <Radio value="option" />
</RadioGroup>

Disabled

Disabled radios cannot be interacted with and display a muted appearance.

Disabled states

Unselected
Selected
<RadioGroup>
  <Radio value="option" disabled />
</RadioGroup>

<RadioGroup value="option">
  <Radio value="option" disabled />
</RadioGroup>

Error Variant

Use the error variant to indicate validation errors or required fields.

Error states

Unselected
Selected
<RadioGroup>
  <Radio value="option" variant="error" />
</RadioGroup>

<RadioGroup value="option">
  <Radio value="option" variant="error" />
</RadioGroup>

Controlled

You can control the radio group state externally using the value and onValueChange props.

Selected value: option1

const [value, setValue] = useState('option1')

<RadioGroup value={value} onValueChange={setValue}>
  <Radio value="option1" />
  <Radio value="option2" />
  <Radio value="option3" />
</RadioGroup>

Horizontal Layout

Use a horizontal layout for inline radio groups.

<RadioGroup orientation="horizontal" className="flex-row gap-6">
  <Radio value="option1" />
  <Radio value="option2" />
  <Radio value="option3" />
</RadioGroup>

All States Overview

Unselected
Selected
Default
Disabled
Error

Accessibility

  • Built on Radix UI Radio Group primitive for robust accessibility
  • Full keyboard support (Arrow keys to navigate, Space to select)
  • Proper ARIA attributes for screen readers
  • Supports aria-label and aria-labelledby for labeling
  • Focus states are clearly visible
  • Only one option can be selected at a time within a group

API Reference

RadioGroup Props

PropTypeDefaultDescription
valuestring-The controlled selected value
defaultValuestring-The default selected value (uncontrolled)
onValueChange(value: string) => void-Callback when selection changes
disabledbooleanfalseDisable all radios in the group
orientation"horizontal" | "vertical""vertical"Layout orientation
namestring-Name for form submission
classNamestring-Additional CSS classes

Radio Props

PropTypeDefaultDescription
valuestringRequiredThe value of this radio option
disabledbooleanfalseWhether the radio is disabled
variant"default" | "error""default"Visual variant
classNamestring-Additional CSS classes