Blocks Design System

RadioGroup and Radio

One choice from a short, visible list, on Base UI. RadioGroup holds the value and the form name; each Radio is an option whose children are its label. For a long list, use Select.

tsx
import { Radio, RadioGroup } from '@blocks/design-system'

Both are client components. A Server Component can render an uncontrolled group with defaultValue; value and onValueChange belong in a client-authored caller.

In a native form

Give the group a name and it submits the selected value. Label the group with aria-labelledby pointing at visible text, aria-label, or a surrounding Field.

Send storm alerts by

Source · radio/alert-delivery.tsx
radio/alert-delivery.tsx
// A Server Component: an uncontrolled group in a native form.
import { Body, Button, Radio, RadioGroup, Stack } from '@blocks/design-system'

export default function AlertDelivery() {
  return (
    <Stack as="form" action="/components/radio" method="get" gap="sm" aria-label="Alert delivery">
      <Body id="delivery-label" fontWeight="semibold" margin="none">
        Send storm alerts by
      </Body>
      <RadioGroup name="delivery" defaultValue="email" aria-labelledby="delivery-label">
        <Radio value="email">Email</Radio>
        <Radio value="sms">Text message</Radio>
        <Radio value="push">Push notification</Radio>
        <Radio value="pager" disabled>
          Pager (retired)
        </Radio>
      </RadioGroup>
      <div>
        <Button type="submit" variant="primary">
          Save delivery
        </Button>
      </div>
    </Stack>
  )
}
Alert delivery

Controlled

Snow depth: 84 in

Source · radio/controlled-units.tsx
radio/controlled-units.tsx
'use client'

import { Body, Radio, RadioGroup, Stack } from '@blocks/design-system'
import { useState } from 'react'

export default function ControlledUnits() {
  const [units, setUnits] = useState('imperial')
  return (
    <Stack gap="sm">
      <RadioGroup aria-label="Units" value={units} onValueChange={(value) => setUnits(String(value))}>
        <Radio value="imperial">Inches and feet</Radio>
        <Radio value="metric">Centimeters and meters</Radio>
      </RadioGroup>
      <Body margin="none">Snow depth: {units === 'metric' ? '213 cm' : '84 in'}</Body>
    </Stack>
  )
}
Units

Keyboard

KeyAction
TabMoves into the group at the selected option, then out of it.
ArrowDown / ArrowRightSelects the next option, skipping disabled ones and wrapping.
ArrowUp / ArrowLeftSelects the previous option.

Props

RadioGroup props
PropTypeDefaultDescription
defaultValueany—The uncontrolled value of the radio button that should be initially selected. To render a controlled radio group, use the `value` prop instead.
disabledbooleanfalseWhether the component should ignore user interaction.
formstring—Identifies the form that owns the radio inputs. Useful when the radio group is rendered outside the form.
inputRefRef<HTMLInputElement>—A ref to access the hidden input element.
namestring—Identifies the field when a form is submitted.
onValueChange((value: any, eventDetails: { … }) => void)—Callback fired when the value changes.
readOnlybooleanfalseWhether the user should be unable to select a different radio button in the group.
renderReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, RadioGroupState>—Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
requiredbooleanfalseWhether the user must choose a value before submitting a form.
valueany—The controlled value of the radio item that should be currently selected. To render an uncontrolled radio group, use the `defaultValue` prop instead.

Also accepts styling escape hatches and a ref, and the native attributes of the element it renders.

Radio props
PropTypeDefaultDescription
value (required)any—The unique identifying value of the radio in a group.
childrenReactNode—The radio's label, rendered next to it inside a `<label>`.
disabledboolean—Whether the component should ignore user interaction.
inputRefRef<HTMLInputElement>—A ref to access the hidden input element.
nativeButtonbooleantrueWhether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (for example, `<div>`).
readOnlyboolean—Whether the user should be unable to select the radio button.
renderReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, RadioRootState>—Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
requiredboolean—Whether the user must choose a value before submitting a form.

Also accepts styling escape hatches and a ref, and the native attributes of the element it renders.

Accessibility

  • The group needs a name; each option’s label is its children.
  • Arrow keys change the selection immediately, so don’t trigger expensive work on every change; save on submit instead.
  • Keep at least one option selected by default when the question needs an answer.