Forms
RadioGroup
Mutually exclusive options built from native radios, so they submit with forms; arrow keys move the selection the same way in every browser.
import { RadioGroup, Radio } from '@reactloom/ui';Examples
With descriptions
import { Radio, RadioGroup } from '@reactloom/ui';
export default function Example() {
return (
<RadioGroup legend="Plan" defaultValue="team" required>
<Radio value="starter" label="Starter" description="Up to 5 members." />
<Radio value="team" label="Team" description="Up to 50 members, SSO." />
<Radio value="enterprise" label="Enterprise" description="Contact sales." disabled />
</RadioGroup>
);
}Horizontal
import { Radio, RadioGroup } from '@reactloom/ui';
export default function Example() {
return (
<RadioGroup legend="Billing cycle" orientation="horizontal" defaultValue="annual">
<Radio value="monthly" label="Monthly" />
<Radio value="annual" label="Annual (save 20%)" />
</RadioGroup>
);
}API reference
RadioGroup props
| Prop | Type | Default |
|---|---|---|
legendrequiredAccessible name. | ReactNode | — |
value / defaultValue | string | null | — |
onValueChange | (value: string) => void | — |
nameGenerated when omitted. | string | — |
requiredSets aria-required and native required. | boolean | false |
orientation | 'vertical' | 'horizontal' | 'vertical' |
error · description | ReactNode | — |
Radio props
| Prop | Type | Default |
|---|---|---|
valuerequired | string | — |
label · description | ReactNode | — |
disabled | boolean | false |
Customization
Extracted from the component’s source on every build, so it matches the code. How the layers fit together is explained in Customization.
State attributes
Target these in your CSS to style states without depending on class names.
| Attribute | Values |
|---|---|
[data-disabled] | present when on |
[data-invalid] | present when on |
[data-size] | present when on |
[data-type] | present when on |
Theme tokens it reads
--pl-color-accent-solid --pl-color-bg-muted --pl-color-bg-subtle --pl-color-bg-surface --pl-color-border-default --pl-color-border-input --pl-color-danger-border --pl-color-fg-default --pl-color-fg-disabled --pl-color-fg-muted --pl-color-fg-on-accent --pl-focus-ring-color --pl-focus-ring-offset --pl-focus-ring-width --pl-font-size-lg --pl-font-size-md --pl-font-size-sm --pl-radius-xs
Accessibility
- role="radiogroup" on a fieldset named by its legend.
- Arrow keys follow the WAI-ARIA radio group pattern in every browser: they skip disabled options, wrap from the last option to the first, and ← / → follow the reading direction. Safari’s native radios stop at the ends and do not mirror in right-to-left layouts, so ReactLoom handles the keys itself.
| Key | Action |
|---|---|
| Tab | Enter / leave the group |
| ↓ / → | Select the next option (wraps; → is the previous option in right-to-left layouts) |
| ↑ / ← | Select the previous option (wraps; ← is the next option in right-to-left layouts) |
Usage guidelines
Do
- Pre-select a sensible default when there is one.
Don’t
- Don’t use radios for more than ~7 options — a Select (Phase 2) scales better.