Examples

With descriptions

Preview
Plan

Up to 5 members.

Up to 50 members, SSO.

Contact sales.

Example.tsx
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

Preview
Billing cycle
Example.tsx
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

RadioGroup props
PropTypeDefault
legendrequired
Accessible name.
ReactNode—
value / defaultValue
string | null—
onValueChange
(value: string) => void—
name
Generated when omitted.
string—
required
Sets aria-required and native required.
booleanfalse
orientation
'vertical' | 'horizontal''vertical'
error · description
ReactNode—

Radio props

Radio props
PropTypeDefault
valuerequired
string—
label · description
ReactNode—
disabled
booleanfalse

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.

AttributeValues
[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.
Keyboard interactions
KeyAction
TabEnter / 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.