Skip to content

RadioGroup

RadioGroup

A single-choice group of RadioItems (role="radiogroup").

- One tab stop (the selected item, else the first enabled one); arrow keys move focus and select (APG radio group), Home/End jump to the ends, disabled items are skipped. A key pressed on a link inside an item's label stays the link's: it neither moves focus nor selects. Items may sit inside Fragments or wrapper elements. Every item needs its own value (a development warning names a value that several items share).
- Inside a Field it is named by the Field label (aria-labelledby) and described by its hint and error.
- With name (or required) it takes part in native forms; a form reset restores defaultValue.

Use RadioGroup.Item (or the flat RadioGroupItem/RadioItem names) for the items. React Server Components cannot access the dotted form, so they import the flat names; dotted access needs a client file. An element of your own (a card with a title and a description) becomes one of the group's radios through useRadioGroupItem, and useRadioGroupContext reads the group's value from content inside it.

Examples

Default

export const Default: Story = {
  args: {
    defaultValue: 'apple',
  },
  render: (args) => (
    <RadioGroup {...args}>
      <RadioItem value="apple" label="Apple" />
      <RadioItem value="banana" label="Banana" />
      <RadioItem value="cherry" label="Cherry" />
    </RadioGroup>
  ),
};

Horizontal

export const Horizontal: Story = {
  args: {
    'aria-label': 'Size',
    orientation: 'horizontal',
    defaultValue: 'medium',
  },
  render: (args) => (
    <RadioGroup {...args}>
      <RadioItem value="small" label="Small" />
      <RadioItem value="medium" label="Medium" />
      <RadioItem value="large" label="Large" />
    </RadioGroup>
  ),
};

Horizontal Stacked

export const HorizontalStacked: Story = {
  args: {
    'aria-label': 'Size',
    orientation: 'horizontal',
    labelPosition: 'below',
    defaultValue: 'medium',
  },
  render: (args) => (
    <RadioGroup {...args}>
      <RadioItem value="small" label="Small" />
      <RadioItem value="medium" label="Medium" />
      <RadioItem value="large" label="Large" />
    </RadioGroup>
  ),
};

Dotted Items

export const DottedItems: Story = {
  args: {
    'aria-label': 'Delivery',
    defaultValue: 'standard',
  },
  render: (args) => (
    <RadioGroup {...args}>
      <RadioGroup.Item value="standard" label="Standard" />
      <RadioGroup.Item value="express" label="Express" />
    </RadioGroup>
  ),
};

Disabled

export const Disabled: Story = {
  args: {
    'aria-label': 'Disabled group',
    defaultValue: 'a',
    disabled: true,
  },
  render: (args) => (
    <RadioGroup {...args}>
      <RadioItem value="a" label="Option A" />
      <RadioItem value="b" label="Option B" />
    </RadioGroup>
  ),
};

Disabled Item

export const DisabledItem: Story = {
  args: {
    'aria-label': 'Plan',
  },
  render: (args) => (
    <RadioGroup {...args}>
      <RadioItem value="free" label="Free" disabled />
      <RadioItem value="pro" label="Pro" />
      <RadioItem value="team" label="Team" />
    </RadioGroup>
  ),
};

Controlled

Selected: red

export const Controlled: Story = {
  args: {
    'aria-label': 'Color',
  },
  render: function ControlledRadioGroup(args) {
    const [value, setValue] = useState('red');
    return (
      <div className="flex flex-col gap-2">
        <RadioGroup
          {...args}
          value={value}
          onValueChange={(next) => {
            setValue(next);
            args.onValueChange?.(next);
          }}
        >
          <RadioItem value="red" label="Red" />
          <RadioItem value="green" label="Green" />
          <RadioItem value="blue" label="Blue" />
        </RadioGroup>
        <p className="text-wave-body-1 text-wave-foreground">Selected: {value}</p>
      </div>
    );
  },
};

In Form

export const InForm: Story = {
  args: {
    'aria-label': 'Shipping speed',
    name: 'shipping',
    required: true,
  },
  render: (args) => (
    <form className="flex flex-col items-start gap-3" onSubmit={(e) => e.preventDefault()}>
      <RadioGroup {...args}>
        <RadioItem value="standard" label="Standard" />
        <RadioItem value="express" label="Express" />
      </RadioGroup>
      <Button type="submit" appearance="primary">
        Continue
      </Button>
    </form>
  ),
};

Label With Subtext

export const LabelWithSubtext: Story = {
  args: {
    'aria-label': 'Delivery speed',
    defaultValue: 'standard',
  },
  render: (args) => {
    const option = (title: string, detail: string) => (
      <span className="flex flex-col">
        <span>{title}</span>{' '}
        <span className="text-wave-caption-1 text-wave-muted-foreground">{detail}</span>
      </span>
    );
    return (
      <RadioGroup {...args}>
        <RadioItem
          value="standard"
          label={option('Standard', 'Arrives in 3 to 5 business days.')}
        />
        <RadioItem
          value="express"
          label={option('Express', 'Arrives tomorrow when ordered before 14:00.')}
        />
      </RadioGroup>
    );
  },
};

Custom Radio Card

Chosen plan: pro
export const CustomRadioCard: Story = {
  args: {
    'aria-label': 'Plan',
    defaultValue: 'pro',
  },
  render: (args) => (
    <RadioGroup {...args}>
      <PlanCard value="free" title="Free" description="One project and community support." />
      <PlanCard value="pro" title="Pro" description="Unlimited projects and email support." />
      <PlanCard
        value="team"
        title="Team"
        description="Shared workspaces. Ask your administrator to enable it."
        disabled
      />
      <PlanSummary />
    </RadioGroup>
  ),
};

Props

NameTypeRequiredDefaultDescription
valuestringNo

Controlled selected value ('' for no selection).

defaultValuestringNo''

Initial selected value for uncontrolled usage (also the value a form reset restores).

onValueChange(value: string) => voidNo

Called with the newly selected value when the selection changes (not when re-selecting).

orientation'horizontal' | 'vertical'No'vertical'

Layout of the radio items (also aria-orientation). Arrow keys follow the APG radio pattern in both layouts: Down/Right select the next item, Up/Left the previous one (Left/Right mirrored under dir="rtl").

labelPosition'after' | 'below'No'after'

Where the items draw their label, unless an item sets its own labelPosition: after the radio (the default) or below it. orientation="horizontal" with labelPosition="below" is Fluent UI's layout="horizontal-stacked"; orientation stands for the rest of its layout (vertical, horizontal).

disabledbooleanNo

Disables every item of the group.

namestringNo

Form field name. With a name, the selected value is submitted with the form. No name is generated: without one the group adds nothing to FormData.

requiredbooleanNo

A value must be selected before the form can be submitted (native validation).

formstringNo

Id of the form the group belongs to, when it is rendered outside that form.

refReact.Ref<HTMLDivElement>No

Ref to the role="radiogroup" element.

Any other prop is passed to the element it renders (HTMLDivElement).

Parts

  • RadioGroup.Item

Stable class names

PartClass
rootwave-radio-group