Radio Button Group

RadioButtonGroup coordinates a set of related radio options so users can make exactly one choice.

tsx
import { RadioButton } from '@/components/ui/wideset/radio-button/RadioButton';
import { RadioButtonGroup } from '@/components/ui/wideset/radio-button/RadioButtonGroup';

<RadioButtonGroup defaultValue="standard">
  <RadioButton value="standard" label="Standard" description="3–5 business days" />
  <RadioButton value="express" label="Express" description="Next business day" />
  <RadioButton value="pickup" label="Pickup" description="Ready in 2 hours" />
</RadioButtonGroup>

Installation

pnpm dlx wideset add radio-button-group

Copies the component and any Wideset components it uses into your project.

Examples

Orientation

Vertical is the default and the safer choice: labels of any length line up and descriptions have room. Go horizontal only for two or three short options with no descriptions. Either way the arrow keys move the selection and the group is a single tab stop.

tsx
import { RadioButton } from '@/components/ui/wideset/radio-button/RadioButton';
import { RadioButtonGroup } from '@/components/ui/wideset/radio-button/RadioButtonGroup';

export default function RadioButtonGroupOrientation() {
  return (
    <div className="gap-ws-14 flex flex-wrap items-start justify-center">
      <RadioButtonGroup orientation="vertical" defaultValue="standard" aria-label="Shipping">
        <RadioButton value="standard" label="Standard" description="3–5 business days" />
        <RadioButton value="express" label="Express" description="Next business day" />
        <RadioButton value="pickup" label="Pickup" description="Ready in 2 hours" />
      </RadioButtonGroup>
      <RadioButtonGroup orientation="horizontal" defaultValue="monthly" aria-label="Billing">
        <RadioButton value="monthly" label="Monthly" />
        <RadioButton value="annual" label="Annual" />
      </RadioButtonGroup>
    </div>
  );
}

States

Disabling the group disables every option and takes the whole set out of the tab order. To rule out a single option, disable that radio instead and say why in its description.

tsx
import { RadioButton } from '@/components/ui/wideset/radio-button/RadioButton';
import { RadioButtonGroup } from '@/components/ui/wideset/radio-button/RadioButtonGroup';

export default function RadioButtonGroupStates() {
  return (
    <div className="gap-ws-14 flex flex-wrap items-start justify-center">
      <RadioButtonGroup defaultValue="standard">
        <RadioButton value="standard" label="Standard" description="3–5 business days" />
        <RadioButton
          value="express"
          label="Express"
          description="Not available for this address"
          disabled
        />
      </RadioButtonGroup>
      <RadioButtonGroup defaultValue="standard" disabled>
        <RadioButton value="standard" label="Standard" description="3–5 business days" />
        <RadioButton value="express" label="Express" description="Next business day" />
      </RadioButtonGroup>
    </div>
  );
}

API reference

NameDescriptionDefault
children

RadioButton items rendered inside the group.

ReactNode
—
className

Additional CSS classes merged with the group root element.

string
—
defaultValue

Initial selected value for uncontrolled usage. Ignored when `value` is provided.

string
—
disabled

Disables every radio in the group.

boolean
—
name

Form field name shared by all radios in the group.

string
—
onValueChange

Fired when the selected value changes.

((value: string) => void)
—
orientation

Layout direction of the radios within the group.

'horizontal''vertical'
'vertical'
required

Marks the group as required in a form context.

boolean
—
value

Controlled selected radio value.

string
—

Accessibility

  • The group renders role="radiogroup". Name it with aria-label or aria-labelledby; inside FormField use WrapperComponent="fieldset" for a group of controls.
  • The group is a single tab stop; the arrow keys move the selection.
tsx
import { RadioButton } from '@/components/ui/wideset/radio-button/RadioButton';
import { RadioButtonGroup } from '@/components/ui/wideset/radio-button/RadioButtonGroup';

<RadioButtonGroup defaultValue="standard">
  <RadioButton value="standard" label="Standard" description="3–5 business days" />
  <RadioButton value="express" label="Express" description="Next business day" />
  <RadioButton value="pickup" label="Pickup" description="Ready in 2 hours" />
</RadioButtonGroup>

Appearance

Orientation

Content

Descriptions

State

Disabled