Components

RadioGroup

Headless single-selection radio group with roving focus.

When to Use

Use RadioGroup when the user must choose exactly one option from a short list and seeing every choice helps the decision. Use CheckboxGroup when several choices may be selected, or Select when the list is long and should stay compact.

Features

  • Manages one selected value.
  • Can be controlled or uncontrolled.
  • Supports horizontal and vertical keyboard navigation.
  • Mirrors horizontal arrow-key navigation in RTL when wrapped in Direction.Provider.
  • Supports optional looping.
  • Renders hidden native radio inputs for form submission when named.
  • Keeps only the selected or first enabled item in the tab order.

Import

import { RadioGroup } from "@flowstack-ui/atom";

Anatomy

<RadioGroup.Root>
  <RadioGroup.Radio value="one" />
  <RadioGroup.Radio value="two" />
</RadioGroup.Root>

API Reference

Root

Owns the selected value, group label, form settings, orientation, and roving focus behavior for every Radio part inside it.

PropTypeDefault
valuestring-
defaultValuestring""
onValueChange(value: string) => void-
namestring-
formstring-
disabledbooleanfalse
requiredbooleanfalse
invalidbooleanfalse
orientation"horizontal" | "vertical""vertical"
loopbooleantrue
ariaLabelstring-
asChildbooleanfalse
renderRenderProp-
ARIA attributeValues
role"radiogroup"
aria-labelValue from ariaLabel when provided
aria-disabledtrue when disabled
aria-requiredtrue when required
aria-invalidtrue when invalid
aria-orientation"horizontal" or "vertical"
Data attributeValues
[data-slot]"radio-group"
[data-orientation]"horizontal" | "vertical"
[data-disabled]Present when disabled
[data-invalid]Present when invalid

Radio

Renders one option, registers it for keyboard navigation, and mirrors the selected value into a hidden native radio input when Root has a name.

PropTypeDefault
valuestringRequired
disabledbooleanGroup state
ariaLabelstring-
asChildbooleanfalse
renderRenderProp-
ARIA attributeValues
role"radio"
aria-checkedtrue when selected
aria-labelValue from ariaLabel when provided
aria-disabledtrue when the Radio or group is disabled
aria-invalidtrue when the group is invalid
Data attributeValues
[data-slot]"radio"
[data-value]Item value
[data-state]"checked" | "unchecked"
[data-disabled]Present when disabled
[data-invalid]Present when invalid

Advanced compound parts can read the group contract with useRadioGroupContext; RadioGroupContextProvider and its context value type are also public for low-level composition.

Examples

Horizontal Group

import { RadioGroup } from "@flowstack-ui/atom";

export default () => (
  <RadioGroup.Root orientation="horizontal" defaultValue="email">
    <RadioGroup.Radio value="email">Email</RadioGroup.Radio>
    <RadioGroup.Radio value="phone">Phone</RadioGroup.Radio>
  </RadioGroup.Root>
);

Accessibility

RadioGroup follows the WAI-ARIA radio group pattern. Root exposes role="radiogroup", each Radio exposes its checked state, and roving tab focus keeps the group to one Tab stop. Provide a group name with aria-labelledby or ariaLabel. Horizontal arrows mirror in RTL through Direction.Provider.

KeyDescription
ArrowDownMoves to the next item when orientation is vertical.
ArrowUpMoves to the previous item when orientation is vertical.
ArrowRightMoves to the next item when orientation is horizontal.
ArrowLeftMoves to the previous item when orientation is horizontal.
HomeMoves to the first enabled item.
EndMoves to the last enabled item.
SpaceSelects the focused Radio through native button activation.
TabEnters or leaves the group through its single roving Tab stop.

Changelog

See CHANGELOG.md.