Radio Group
A set of mutually exclusive options where only one can be selected.
Import
import { RadioGroup, RadioItem } from '@matix/components/radio-group';Usage
The quickest way is to pass an options array.
Composition
For more control, use RadioItem children directly.
<RadioGroup defaultValue="light">
<RadioItem value="light" label="Light" />
<RadioItem value="dark" label="Dark" />
<RadioItem value="system" label="System" />
</RadioGroup>Horizontal
<RadioGroup
orientation="horizontal"
defaultValue="sm"
options={[
{ value: 'sm', label: 'Small' },
{ value: 'md', label: 'Medium' },
{ value: 'lg', label: 'Large' },
]}
/>Disabled
Individual items or the entire group can be disabled.
<RadioGroup defaultValue="a">
<RadioItem value="a" label="Option A" />
<RadioItem value="b" label="Option B" disabled />
<RadioItem value="c" label="Option C" />
</RadioGroup>With Field
<Field label="Notification method" description="Choose how you'd like to be notified.">
<RadioGroup
defaultValue="email"
options={[
{ value: 'email', label: 'Email' },
{ value: 'sms', label: 'SMS' },
]}
/>
</Field>Custom Styles
import * as stylex from '@stylexjs/stylex';
const custom = stylex.create({
spaced: { gap: '16px' },
});
<RadioGroup
sx={custom.spaced}
defaultValue="a"
options={[
{ value: 'a', label: 'Option A' },
{ value: 'b', label: 'Option B' },
]}
/>;API Reference
RadioGroup
| Prop | Type | Default | Description |
|---|---|---|---|
options | RadioOption[] | — | Array of { value, label, disabled? } for quick setup |
orientation | 'vertical' | 'horizontal' | 'vertical' | Layout direction |
defaultValue | string | — | Initial selected value (uncontrolled) |
value | string | — | Controlled selected value |
onValueChange | (value: string) => void | — | Called when selection changes |
sx | StyleXStyles | — | StyleX style override |
RadioItem
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | — | Value for this option |
label | ReactNode | — | Label rendered next to the radio |
disabled | boolean | false | Disable this option |
sx | StyleXStyles | — | StyleX style override |
Accessibility
- Wraps Base UI RadioGroup — full
role="radiogroup"androle="radio"semantics. - Arrow keys move selection within the group (roving tabindex).
- Labels are associated automatically.
- Focus ring via
:focus-visible.
Keyboard
| Key | Action |
|---|---|
Arrow Down / Arrow Right | Select next option |
Arrow Up / Arrow Left | Select previous option |
Tab | Moves focus into / out of the group |