JGuang

RadioList

RadioList · Astryx

Preview
npm install @astryxdesign/core@0.7.1 @astryxdesign/theme-neutral@0.7.1 @stylexjs/stylex@0.19.0

RadioList

A group of options where only one can be selected at a time. All options are visible at once, making it easy to compare choices. Use it when users need to pick one option from a small set.

Installation

npm install @astryxdesign/core@0.7.1 @astryxdesign/theme-neutral@0.7.1 @stylexjs/stylex@0.19.0

Requires React 19+, base CSS and a Theme provider. See Setup.

Radio List

A group of options where only one can be selected at a time. All options are visible at once, making it easy to compare choices. Use it when users need to pick one option from a small set.

PropTypeDefaultDescription
label *stringLabel text for the radio group (always rendered for accessibility).
value *stringThe currently selected value.
onChange *(value: string) => voidCallback fired when the selected value changes.
children *ReactNodeRadioListItem elements.
isLabelHiddenbooleanfalseWhether to visually hide the label.
descriptionstringDescription text displayed below the label.
orientation'vertical' | 'horizontal''vertical'Layout direction of the radio items.
isDisabledbooleanfalseWhether all radio items are disabled.
htmlNamestringThe HTML name attribute shared by the radio inputs, useful for form submissions. When omitted, a unique internal name still groups the radios.
disabledMessagestringExplains why the group is disabled. Applies to the whole-group disabled state (isDisabled), not per item. With isDisabled, shows a tooltip on hover/keyboard focus and keeps the radios focusable via aria-disabled (selection stays blocked). Use this instead of wrapping a disabled RadioList in Tooltip. Disabled controls swallow the hover events an external Tooltip needs.
isRequiredbooleanfalseWhether the radio group is required.
isOptionalbooleanfalseWhether the field is optional (mutually exclusive with isRequired).
status{type: 'warning' | 'error' | 'success', message?: string}Status indicator ({ type, message }).
size'sm' | 'md''md'Size of the radio controls.
labelTooltipstringTooltip text for an info icon next to the label.
widthSizeValueWidth of the field (number = pixels, string used as-is, e.g. "100%"). Sizes the whole field (label, control, and status) so they stay aligned.
containerXstyleStyleXStylesStyleX styles for the field container (label, control, and status together). No effect inside InputGroup (style the InputGroup instead) or in a horizontal-labels FormLayout. Root xstyle, className, and style are not accepted.
containerClassNamestringClass name for the field container. Same targeting as containerXstyle.
containerStyleCSSPropertiesInline styles for the field container. Same targeting as containerXstyle.
controlXstyleStyleXStylesStyleX styles for the visual control box: the element that paints the border and background and holds icons and end controls. Never the native input.
controlClassNamestringClass name for the visual control box.
controlStyleCSSPropertiesInline styles for the visual control box.

Usage guidance

  • Keep the number of options small: typically 2 to 7 choices.
  • Use clear, concise labels that differentiate each option at a glance.
  • Pre-select a default option when there's a sensible default; don't leave the group empty unless the choice is optional.
  • Avoid: Use when multiple selections are needed; use CheckboxList instead.
  • Avoid: Use for long lists; use Selector for better discoverability.
  • Avoid: Use horizontal layout with more than 4 options; it wraps awkwardly.
  • Avoid: Wrap a disabled RadioList in Tooltip to explain why it is disabled; disabled controls swallow the hover events the wrapper needs. Use the disabledMessage prop instead.

Theming API

{
  "targets": [
    {
      "className": "astryx-radio-list",
      "visualProps": [
        "orientation",
        "size"
      ]
    },
    {
      "className": "astryx-radio-list-item",
      "visualProps": [
        "size"
      ],
      "states": [
        "selected",
        "disabled"
      ]
    },
    {
      "className": "astryx-radio-indicator",
      "visualProps": [
        "size"
      ],
      "states": [
        "checked",
        "disabled"
      ]
    },
    {
      "className": "astryx-radio-indicator-dot",
      "visualProps": [
        "size"
      ]
    }
  ]
}

RadioListItem

Accessibility

  • Radio circle: The circle edge (unselected) and fill (selected) must have at least 3:1 contrast with the surface behind them. For Hover and Pointer down, measure the final colors after the tint and the pressed overlay are applied. — 3:1

Anatomy

  • Header: Optional heading above the radio list.
  • Children: The radio list items rendered as selectable options.
  • Label/Value: The text label and associated value for each radio item.

Radio List Item

Individual radio item with label, description, and content slots.

PropTypeDefaultDescription
label *ReactNodePrimary label for the radio item. Rich labels may contain links or buttons, which keep their own behavior without selecting the item. The label text names the radio; use aria-label only when that text is absent, or retain every visible label word in the override.
aria-labelstringPlain-text accessible name for the radio, applied to the control rather than the row. It overrides the name derived from the label. Use it when a rich label has no visible text; otherwise retain every visible label word.
value *stringValue of this radio item.
descriptionReactNodeSecondary content displayed below the label. Links and buttons keep their own click behaviour — the row only delegates clicks from its non-interactive surface to the radio.
isDisabledbooleanfalseWhether this individual radio item is disabled.
startContentReactNodeContent to render before the radio circle.
endContentReactNodeContent to render after the label.

Examples

  • Radio List Item: Radio list items with labels, descriptions, and different states including disabled.
  • Radio List:
  • RadioList — Horizontal Layout: Radio list with horizontal orientation for compact selections.
  • RadioListItem — Basic: Radio items with labels and descriptions inside a controlled RadioList. Use for single-choice option groups like shipping methods.
  • RadioList — Pricing Tier: Radio list with pricing info in end content for plan selection.
  • RadioList — With Descriptions: Radio list with descriptions on the group and each item.
  • RadioList — With Validation: Required radio list with an error message when nothing is selected.