Radio group

A group of radio buttons for selecting one option from a set.

Import

import { RadioGroup } from '@oztix/roadie-components/radio-group'

Examples

Default

<RadioGroup>
  <RadioGroup.Item value='email' label='Email' />
  <RadioGroup.Item value='phone' label='Phone' />
  <RadioGroup.Item value='post' label='Post' />
</RadioGroup>

With Field

Wrap RadioGroup in Field for consistent layout, labels, and error handling.

<Field required>
  <Field.Label showIndicator>Contact method</Field.Label>
  <RadioGroup>
    <RadioGroup.Item value='email' label='Email' />
    <RadioGroup.Item value='phone' label='Phone' />
    <RadioGroup.Item value='post' label='Post' />
  </RadioGroup>
</Field>

With standalone label

RadioGroup also has its own RadioGroup.Label for standalone usage without a Field wrapper.

<RadioGroup required>
  <RadioGroup.Label showIndicator>Contact method</RadioGroup.Label>
  <RadioGroup.Item value='email' label='Email' />
  <RadioGroup.Item value='phone' label='Phone' />
  <RadioGroup.Item value='post' label='Post' />
</RadioGroup>

Variants

Horizontal direction

<RadioGroup direction='horizontal'>
  <RadioGroup.Item value='small' label='Small' />
  <RadioGroup.Item value='medium' label='Medium' />
  <RadioGroup.Item value='large' label='Large' />
</RadioGroup>

Emphasis

Use the emphasis prop on the Root to control the visual weight of all items.

Normal

<RadioGroup emphasis='normal'>
  <RadioGroup.Item value='standard' label='Standard delivery' />
  <RadioGroup.Item value='express' label='Express delivery' />
  <RadioGroup.Item value='overnight' label='Overnight delivery' />
</RadioGroup>

States

<div className='grid gap-4'>
  <div className='grid gap-1'>
    <p className='text-sm text-subtle'>Default</p>
    <RadioGroup>
      <RadioGroup.Item value='a' label='Option A' />
      <RadioGroup.Item value='b' label='Option B' />
    </RadioGroup>
  </div>
  <div className='grid gap-1'>
    <p className='text-sm text-subtle'>Disabled</p>
    <RadioGroup disabled>
      <RadioGroup.Item value='a' label='Option A' />
      <RadioGroup.Item value='b' label='Option B' />
    </RadioGroup>
  </div>
</div>

Accessibility

  • Keyboard: Arrow Up/Arrow Down moves between radio items. Space selects the focused item. Base UI manages roving tabindex.
  • ARIA: Base UI Radio sets role="radiogroup" on the root and role="radio" with aria-checked on each item automatically.
  • Grouping: Wrap in a Fieldset with a Legend to provide a group label for screen readers.

API reference

RadioGroup

Base UI
disabled?boolean

Whether the component should ignore user interaction.

Defaults to false.

readOnly?boolean

Whether the user should be unable to select a different radio button in the group.

Defaults to false.

required?boolean

Whether the user must choose a value before submitting a form.

Defaults to false.

name?string

Identifies the field when a form is submitted.

value?any

The controlled value of the radio item that should be currently selected. To render an uncontrolled radio group, use the `defaultValue` prop instead.

defaultValue?any

The uncontrolled value of the radio button that should be initially selected. To render a controlled radio group, use the `value` prop instead.

onValueChange?((value: any, eventDetails: { reason: "none"; event: Event; cancel: () => void; allowPropagation: () => void; isCanceled: boolean; isPropagationAllowed: boolean; trigger: Element; }) => void)

Callback fired when the value changes.

inputRef?Ref<HTMLInputElement>

A ref to access the hidden input element.

direction?"horizontal" | "vertical" | null
emphasis?"subtler" | "normal"
invalid?boolean

RadioGroup.ErrorText

No additional props — forwards all standard HTML attributes to the underlying element.

RadioGroup.HelperText

No additional props — forwards all standard HTML attributes to the underlying element.

RadioGroup.Item

Base UI
label?string
description?string

Inherited from RadioRootProps

valueany

The unique identifying value of the radio in a group.

disabled?boolean

Whether the component should ignore user interaction.

required?boolean

Whether the user must choose a value before submitting a form.

readOnly?boolean

Whether the user should be unable to select the radio button.

inputRef?Ref<HTMLInputElement>

A ref to access the hidden input element.

Inherited from NonNativeButtonProps

nativeButton?boolean

Whether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `true` if the rendered element is a native button.

Defaults to false.

RadioGroup.Label

showIndicator?boolean