Components
Radio
Base UI radios and a managed RadioGroup with keyboard navigation.
Radio is a Base UI radio. RadioGroup manages a set of radios with a shared name, controlled or
uncontrolled value, orientation, disabled, required, and read-only states, plus Base UI keyboard
navigation and form integration.
Render Radio inside a RadioGroup. Import both from @orkest/ui/client.
Live preview#
import { useState } from 'react';
import { Radio, RadioGroup } from '@orkest/ui/client';
export function Example() {
const [value, setValue] = useState('standard');
return (
<RadioGroup
aria-label="Plan"
value={value}
onValueChange={setValue}
orientation="horizontal"
>
<Radio value="standard" label="Standard" />
<Radio value="pro" label="Pro" />
<Radio value="enterprise" label="Enterprise" />
</RadioGroup>
);
}Vertical and horizontal#
orientation controls layout only. The default is vertical; horizontal groups wrap when needed.
import { Radio, RadioGroup } from '@orkest/ui/client';
export function Example() {
return (
<RadioGroup aria-label="Notifications" defaultValue="all">
<Radio value="all" label="All activity" />
<Radio value="mentions" label="Mentions only" />
<Radio value="none" label="Nothing" />
</RadioGroup>
);
}Sizes and disabled#
RadioGroup passes size to its radios. A radio can override the group size with its own size.
import { Stack } from '@orkest/ui';
import { Radio, RadioGroup } from '@orkest/ui/client';
export function Example() {
return (
<Stack gap={4}>
<RadioGroup aria-label="Small plan" size="sm" defaultValue="basic">
<Radio value="basic" label="Basic" />
<Radio value="pro" label="Pro" />
</RadioGroup>
<RadioGroup aria-label="Disabled plan" defaultValue="basic" disabled>
<Radio value="basic" label="Disabled option" />
<Radio value="pro" label="Another option" />
</RadioGroup>
</Stack>
);
}Props#
Radio#
| Prop | Type | Default |
|---|---|---|
value | string | — |
| Option value used by RadioGroup for selection and form submission. | ||
disabled | boolean | false |
| Disables the radio. A disabled group disables every radio. | ||
required | boolean | false |
| Requires a selection in the group. | ||
readOnly | boolean | false |
| Allows focus but prevents changing the selected value. | ||
size | 'sm' | 'md' | 'lg' | 'md' |
| Control and label size. Inherits from RadioGroup when omitted. | ||
label | ReactNode | — |
| Label rendered beside the control. | ||
inputRef | Ref<HTMLInputElement> | — |
| Ref to the hidden native input used for form submission. | ||
native attributes | Base UI Radio Root props | — |
| ARIA attributes, id, style, and ref are forwarded to the radio root. className styles the label wrapper. | ||
RadioGroup#
| Prop | Type | Default |
|---|---|---|
name | string | — |
| Shared form name. A stable generated name is used when omitted. | ||
value | string | — |
| Controlled selected value. | ||
defaultValue | string | — |
| Initial selected value for uncontrolled usage. | ||
onValueChange | (value: string) => void | — |
| Called with the next selected value. | ||
disabled | boolean | false |
| Disables every radio in the group. | ||
required | boolean | false |
| Requires a selection for form validation. | ||
readOnly | boolean | false |
| Allows focus but prevents changing the selected value. | ||
invalid | boolean | false |
| Exposes the group as invalid through aria-invalid. | ||
orientation | 'horizontal' | 'vertical' | 'vertical' |
| Layout direction and aria-orientation. | ||
size | 'sm' | 'md' | 'lg' | 'md' |
| Size applied to radios that do not set their own size. | ||
native attributes | Base UI RadioGroup props | — |
| ARIA attributes, form, inputRef, className, style, and ref are forwarded to the group. | ||
Accessibility#
RadioGrouprendersrole="radiogroup"; radios renderrole="radio"with hidden native inputs for form submission.- Give
RadioGroupan accessible name witharia-label,aria-labelledby, orFieldLabel. - Base UI handles arrow-key navigation and selection within the group.
- A radio cannot be unchecked by clicking it again. The user must select another option.
disabled,required, andreadOnlyare exposed on the group and applied to each radio.- Focus is shown on the custom control with
:focus-visible.