Radio Group

A set of mutually exclusive options where only one can be selected.

Import

import { RadioGroup, RadioItem } from '@matix/components/radio-group';

Usage

The quickest way is to pass an options array.

Composition

For more control, use RadioItem children directly.

<RadioGroup defaultValue="light">
  <RadioItem value="light" label="Light" />
  <RadioItem value="dark" label="Dark" />
  <RadioItem value="system" label="System" />
</RadioGroup>

Horizontal

<RadioGroup
  orientation="horizontal"
  defaultValue="sm"
  options={[
    { value: 'sm', label: 'Small' },
    { value: 'md', label: 'Medium' },
    { value: 'lg', label: 'Large' },
  ]}
/>

Disabled

Individual items or the entire group can be disabled.

<RadioGroup defaultValue="a">
  <RadioItem value="a" label="Option A" />
  <RadioItem value="b" label="Option B" disabled />
  <RadioItem value="c" label="Option C" />
</RadioGroup>

With Field

<Field label="Notification method" description="Choose how you'd like to be notified.">
  <RadioGroup
    defaultValue="email"
    options={[
      { value: 'email', label: 'Email' },
      { value: 'sms', label: 'SMS' },
    ]}
  />
</Field>

Custom Styles

import * as stylex from '@stylexjs/stylex';

const custom = stylex.create({
  spaced: { gap: '16px' },
});

<RadioGroup
  sx={custom.spaced}
  defaultValue="a"
  options={[
    { value: 'a', label: 'Option A' },
    { value: 'b', label: 'Option B' },
  ]}
/>;

API Reference

RadioGroup

PropTypeDefaultDescription
optionsRadioOption[]—Array of { value, label, disabled? } for quick setup
orientation'vertical' | 'horizontal''vertical'Layout direction
defaultValuestring—Initial selected value (uncontrolled)
valuestring—Controlled selected value
onValueChange(value: string) => void—Called when selection changes
sxStyleXStyles—StyleX style override

RadioItem

PropTypeDefaultDescription
valuestring—Value for this option
labelReactNode—Label rendered next to the radio
disabledbooleanfalseDisable this option
sxStyleXStyles—StyleX style override

Accessibility

  • Wraps Base UI RadioGroup — full role="radiogroup" and role="radio" semantics.
  • Arrow keys move selection within the group (roving tabindex).
  • Labels are associated automatically.
  • Focus ring via :focus-visible.

Keyboard

KeyAction
Arrow Down / Arrow RightSelect next option
Arrow Up / Arrow LeftSelect previous option
TabMoves focus into / out of the group