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.
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.
Source · 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>
)
}Controlled
Snow depth: 84 in
Source · 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>
)
}Keyboard
| Key | Action |
|---|---|
| Tab | Moves into the group at the selected option, then out of it. |
| ArrowDown / ArrowRight | Selects the next option, skipping disabled ones and wrapping. |
| ArrowUp / ArrowLeft | Selects the previous option. |
Props
| Prop | Type | Default | Description |
|---|---|---|---|
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. |
disabled | boolean | false | Whether the component should ignore user interaction. |
form | string | — | Identifies the form that owns the radio inputs. Useful when the radio group is rendered outside the form. |
inputRef | Ref<HTMLInputElement> | — | A ref to access the hidden input element. |
name | string | — | Identifies the field when a form is submitted. |
onValueChange | ((value: any, eventDetails: { … }) => void) | — | Callback fired when the value changes. |
readOnly | boolean | false | Whether the user should be unable to select a different radio button in the group. |
render | ReactElement<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. |
required | boolean | false | Whether the user must choose a value before submitting a form. |
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. |
Also accepts styling escape hatches and a ref, and the native attributes of the element it renders.
| Prop | Type | Default | Description |
|---|---|---|---|
value (required) | any | — | The unique identifying value of the radio in a group. |
children | ReactNode | — | The radio's label, rendered next to it inside a `<label>`. |
disabled | boolean | — | Whether the component should ignore user interaction. |
inputRef | Ref<HTMLInputElement> | — | A ref to access the hidden input element. |
nativeButton | boolean | true | Whether 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>`). |
readOnly | boolean | — | Whether the user should be unable to select the radio button. |
render | ReactElement<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. |
required | boolean | — | 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.