Skip to content

[RFC] Standalone radio control — the RadioInput/RadioControl primitive (spec for #4724) #4755

Open

Description

@freddymeta

Problem Statement

The radio family has no standalone control. RadioList + RadioListItem cover the grouped-field case, but RadioListItem reads RadioListContext and throws if rendered outside a RadioList:

RadioListItem must be used within an RadioList

So there is no way to render a single radio in a bespoke layout — a comparison cell, a pricing card header, a custom two-column arrangement — without standing up a whole RadioList (its Field chrome, label, status, group semantics). The checkbox family already solved this: CheckboxInput is the standalone labeled control, and CheckboxList / CheckboxListItem compose it. The radio family is missing that bottom layer.

This RFC specifies that missing primitive and, importantly, asks the maintainers to settle its shape and name before the implementation lands — the current draft PR (#4724) added it as RadioControl but diverges from sibling conventions (name/checked/optional-label/keepFocusableWhenDisabled), which a review correctly flagged. The convergence work is straightforward; the design questions below are not, and they are what this issue is for.

Evidence of Demand

Product-neutral cases where a radio must render outside a RadioList field:

  • Pricing cards: each plan card is a large selectable surface with a radio in the corner; the cards are laid out in a Grid, not a vertical RadioList.
  • Comparison tables: a radio per column header to pick "the active plan," inside Table cells.
  • Segmented custom layouts: a radio embedded in a bespoke row that already owns its own label, description, and end content.
  • Settings rows composed from Item/ListItem where the row — not a RadioList — owns the layout.

In every case the consumer wants the control, not RadioList's field wrapper. Today they either misuse RadioListItem (throws) or hand-roll a native <input type="radio"> (loses theming, the astryx-radio targets, focus ring, forced-colors handling, and hover treatment).

Why Existing Components Don't Cover This

  • RadioList is the group field (label + status + Field chrome + roving-tabindex management). It is the wrong layer for a single control in a custom surface.
  • RadioListItem is a row (start content + label + description + end content) and hard-requires RadioListContext.
  • There is no RadioInput analogous to CheckboxInput.

Prior Art (internal + external)

  • In-system sibling: CheckboxInput — the standalone labeled boolean control. CheckboxListItem composes it with isLabelHidden and delegates row clicks via Item/ListItem interactiveRef. This is the pattern the radio family should mirror.
  • External: Radix RadioGroup.Item, React Aria Radio, MUI Radio, Ant Radio — all expose a single radio control that must live inside a group/provider for selection semantics. None expose a truly standalone single radio that toggles on and off, because a lone radio can't be deselected by clicking it (native behavior). That constraint is central to the shape question below.

Use Cases the API Must Handle

# Case Scenario
1 Simple/default One radio in a custom layout, controlled, with an accessible name.
2 Configured size, isDisabled, isRequired, a disabled-reason.
3 Controlled group Several controls sharing a group name, one selected, selecting one deselects the rest.
4 Composed A radio inside a Card / Table cell / bespoke Item row that owns the visible label.
5 Edge Disabled-with-reason must stay keyboard- and AT-discoverable; forced-colors; RTL.
6 Migration RadioListItem recomposed on top of the primitive with no behavior change for existing RadioList consumers.

Candidate API Shapes (arbitration)

Option A — bare RadioControl (control only)

Renders just the circle + dot; the accessible name is required and applied as aria-label; no visible label text.

<RadioControl
  label="Pro"            // required — accessible name (aria-label)
  htmlName="plan"        // optional; generated fallback for grouping
  value="pro"
  isChecked={value === 'pro'}
  onChange={(v, e) => setValue(v)}
/>
  • Converges naming to siblings: htmlName?, isChecked, label required, onChange(value, e).
  • Disabled-reason via disabledMessage? (mirrors CheckboxInput), replacing the internal keepFocusableWhenDisabled boolean.
  • Pro: smallest surface; a true low-level primitive. Con: label renders nothing visible, so "labelled" means "aria-label only" — a subtle mismatch with CheckboxInput, where label is visible unless isLabelHidden.

Option B — full RadioInput (the CheckboxInput twin)

A fully labeled control: circle + visible label + description + status + disabledMessage, isLabelHidden to hide the label. RadioListItem composes it exactly as CheckboxListItem composes CheckboxInput (hidden label + row click delegation).

<RadioInput
  label="Pro"
  description="Everything in Basic, plus…"
  htmlName="plan"
  value="pro"
  isChecked={value === 'pro'}
  onChange={(v, e) => setValue(v)}
/>
  • Pro: perfect family symmetry; label/isLabelHidden/description/status/disabledMessage all mean exactly what they mean on CheckboxInput; resolves the "same word, opposite behavior" objection cleanly.
  • Con: larger surface; and recomposing RadioListItem on it changes RadioListItem's rendered output (drops the external <label htmlFor> in favor of a hidden label on the control + click delegation). That's a deliberate, reviewable change, not a byte-identical refactor.

Option C — relax RadioListItem's throw (no new export)

Give RadioListItem a standalone mode (like CheckboxListItem's isChecked/onCheck) so it renders outside a RadioList instead of throwing. No new component.

<RadioListItem label="Pro" value="pro" isChecked={value === 'pro'} onCheck={() => setValue('pro')} />
  • Pro: zero new public component; smallest API-surface delta. Con: RadioListItem is a row abstraction — it still carries row layout you may not want in a Card/cell; and it doesn't give you the bare control.

Recommendation

Lead with Option B (RadioInput) — it is the most convergent with the existing checkbox family and makes every shared prop mean the same thing across the two families, which is the strongest signal from the review. Fall back to Option A if the maintainers prefer to keep the primitive bare and not expand RadioListItem's output. Option C is viable only if the team decides a standalone bare control isn't wanted at all.

This should be vibe-tested per [API Arbitration] with naive prompts across use cases 1–6 (single radio in a card; a controlled group; a radio in a table cell; disabled-with-reason) before the shape is locked. I'm happy to run that and post results here.

Convergence Requirements (apply to whichever shape wins)

A prior review of the draft PR enumerated fixes that any final shape must satisfy:

  1. Naming → htmlName? (not name), isChecked (not checked), required label (+ isLabelHidden for Options B), disabledMessage? (not keepFocusableWhenDisabled). No eslint-disable on @astryx/boolean-prop-naming.
  2. Always has an accessible name — label required so a standalone control can't ship unnamed.
  3. xstyle/className/style land on the root wrapper, not the zero-opacity <input>.
  4. radioScope on the control's own wrapper so a standalone control has a hover state (today it only hovers inside a RadioListItem row).
  5. New public surface → spec'd + vibe-tested + maintainer sign-off (this issue).
  6. Focus ring on the disabled-with-reason path (!isDisabled || keepsFocusable).
  7. {...rest} precedence — contract props (type, role, computed id, aria-*) set after {...rest}; owned handlers composed via composeEventHandlers, not clobbered.
  8. onChange(value, e) — hand back the event (matches CheckboxInput).
  9. Docs — a theming block for astryx-radio/astryx-radio-dot discoverable from the component's own doc, tokens for the raw dimensions, and aria-describedby documented only where actually supported.

Tracking

Implementation lands in PR #4724 once the shape is settled here. Author: freddymeta.

Activity

  1. added
    enhancement
    on Aug 6, 2026
  2. freddymeta commented on Aug 6, 2026

    @freddymeta
    ContributorAuthor

    API Arbitration — vibe test results (A vs B vs C)

    Ran the arbitration from the spec: three isolated blank-slate agents, each given only its option's skill doc (no knowledge of the others, no other design system), building the same 5 naive UX prompts (prompts describe UX, never name props). Prompts: (P1) plan-picker cards, (P2) labeled single-select group, (P3) selectable indicator in table headers, (P4) locked row with a why-disabled explanation, (P5) a single on/off circular control.

    Per-prompt outcome

    Prompt A — RadioControl (bare) B — RadioInput (CheckboxInput twin) C — RadioListItem standalone
    P1 cards ✅ composed bare control into a custom card corner; <label> wrapper made the card clickable 🟡 visible label competed with the card's own text — needs isLabelHidden (agent didn't reach for it) 🟡 inline style on the row root; agent flagged risk of fighting the item's internal padding/indicator layout
    P2 labeled group 🟡 had to hand-build label markup next to the control ✅ label+description mapped 1:1 ✅ label+description mapped 1:1
    P3 indicator in header ✅ descriptive aria-label, clean ✅ isLabelHidden — agent found it and used it cleanly 🟡 full label+description row is too heavy for a header cell; no indicator-only mode
    P4 disabled + reason ✅ isDisabled+disabledMessage, two props ✅ cleanest — near-verbatim the doc example ❌ fails the task — standalone has no reason-tooltip; agent forced to a raw <div title> that doesn't show on keyboard focus (requirement not met)
    P5 on/off toggle ✅ correctly rejected the lone radio; built On/Off pair ✅ correctly rejected; flagged "use a checkbox" ✅ correctly rejected; built On/Off pair

    Cross-cutting findings (all three)

    • Every option wanted a group wrapper with a group label/legend and an orientation/direction — for P2 all three hand-rolled <fieldset>/<legend> for the group's accessible name. That points at a separate gap: RadioList isn't discoverable as the grouping primitive from a control-level doc (and there's no lightweight RadioGroup). Not blocking this decision, but worth a follow-up.
    • P1 "cards" is a Card/selection concern, not a radio concern — no radio primitive should own card chrome; all three correctly reached for their own layout. (This is the SelectableCard composition space.)
    • P5 confirms the anti-pattern holds — none of the three shipped a lone toggle; the "single circular control you can turn off" ask is genuinely a checkbox, exactly as documented.

    Read

    • C is eliminated. It fails P4 outright — the disabled-with-reason pattern is a first-class Astryx behavior (disabledMessage on Selector/CheckboxInput/RadioList), and standalone RadioListItem can't express it without wrapping back in a RadioList. Cramming a full row into a header cell (P3) is also awkward. Standalone mode on a row abstraction is the wrong layer.
    • A and B are close, and split by layer:
      • A (bare control) composes marginally better into bespoke surfaces (P1 card corner, P3 header) because there's no label to work around.
      • B (labeled control) is the superset: isLabelHidden neutralizes A's only edge (the P3 agent proved this), it wins the common labeled case (P2) and the disabled case (P4) outright, and it's family-symmetric with CheckboxInput — every shared prop (label/isLabelHidden/description/status/disabledMessage/isChecked) means the same thing across the checkbox and radio families.

    Recommendation (unchanged, now data-backed): Option B — RadioInput

    RadioInput as the labeled control mirroring CheckboxInput, with RadioListItem composing it the way CheckboxListItem composes CheckboxInput (hidden label on the control + row-click delegation). isLabelHidden covers the bespoke-surface cases A seemed to win.

    The one tradeoff to sign off on: recomposing RadioListItem on RadioInput changes RadioListItem's rendered output (hidden-label-on-control + click delegation instead of today's external <label htmlFor>). That's a deliberate, reviewable change — and it makes the radio family structurally identical to the checkbox family, which is the point.

    If maintainers prefer the absolute-minimal primitive over family symmetry, A is the clean fallback. Either way, C is out.

    Happy to proceed on whichever of A/B you pick; I'll hold the #4724 implementation until then.

  3. freddymeta commented on Aug 6, 2026

    @freddymeta
    ContributorAuthor

    Revised recommendation: Option A — RadioControl (correcting my earlier lean toward B)

    Reconsidering the arbitration, I was optimizing for name-symmetry with CheckboxInput and under-weighted a naming-taxonomy fact that points the other way:

    In Astryx, *Input names a labeled form field, not a bare control. TextInput, NumberInput, DateInput, FileInput, CheckboxInput are all Field-based, and each has a natural standalone use — a single CheckboxInput ("Accept terms") is a valid field on its own.

    A radio has no standalone-field use. A lone radio is an anti-pattern — it can't be deselected (all three options' P5 in the vibe test correctly refused to ship one). So RadioInput would name a standalone labeled radio field that has no valid standalone case. That's the "strange" — the concept doesn't transfer.

    The thing the radio family is actually missing is the bare control (the circle) as a composition primitive for custom surfaces (cards, table cells, bespoke rows). Note the checkbox family doesn't export its bare control at all — it's internal to CheckboxInput. So B's "family symmetry" was matching the name of a different layer (a field), not a true sibling.

    RadioControl names the primitive honestly. And it resolves the "label renders nothing visible" objection rather than dodging it: for a control primitive, label → aria-label is the documented icon-only-Button convention (API Conventions → Accessibility: "Icon-only buttons: label used as aria-label when no visible text"). So a required label applied as the accessible name is convention-aligned for a control — not the "same word, opposite behavior" divergence it would be for a field.

    What ships (Option A, convergence applied)

    • RadioControl — the bare control. label required → aria-label (icon-only-Button convention; fixes "can ship unnamed"). htmlName?, isChecked, value, onChange(value, e), size?, isDisabled?, isRequired?, disabledMessage?. No eslint-disable.
    • RadioListItem keeps composing it, behavior stable (its visible label still names + toggles the radio; the control isn't double-named). 44 existing tests stay green.
    • All convergence items from the spec: xstyle/className/style on the root wrapper, radioScope on the control's own wrapper (standalone hover), focus ring on the disabled-with-reason path, {...rest} precedence + composeEventHandlers, doc theming/tokens/aria-describedby.

    The vibe data still supports this

    A and B were close and split by layer; C was eliminated (fails disabled-with-reason). Between A and B, A is the honest primitive and B mis-names a field. The one thing B "won" — the labeled cases — is served by RadioListItem (the labeled row) composing RadioControl, which is the existing composition. So: bare RadioControl primitive + RadioListItem for the labeled/grouped case, no RadioInput.

    Maintainers: still your call on whether the primitive should exist and land in core (contributor API gate). But if it does, the shape is RadioControl, not RadioInput. Proceeding to apply the convergence on this shape.

  4. freddymeta commented on Aug 6, 2026

    @freddymeta
    ContributorAuthor

    Shape decision: A — bare RadioControl (settled)

    After further discussion, the shape settled on Option A — the bare control (RadioControl), not Option B (RadioInput).

    The reasoning is simple and correct: *Input in Astryx is always a labeled form field (CheckboxInput, TextInput, NumberInput, DateInput). A lone radio has no valid standalone-field use case — you never need a full field wrapper (label + description + status chrome) around a single radio sitting in a card corner or table header. The missing piece was always the composition primitive (the circle), which is what RadioControl is. RadioListItem composes it the same way as before.

    The *Input name would be structurally misleading — it implies field-level chrome that doesn't exist here.

    Implementation is pushed (b961e2f9e on #4724) with all convergence requirements from the review addressed:

    • htmlName?/isChecked/onChange(value, e)/disabledMessage (no eslint-disable)
    • Required label → aria-label (icon-only-Button convention — the control has no visible text)
    • xstyle/className/style on the root wrapper
    • radioScope on own wrapper (standalone hover works)
    • Focus ring on the disabled-with-reason path
    • {...rest} before contract props
    • Generated group name fallback when htmlName is omitted
    • RadioListItem composes unchanged (adapts (value, e) → value-only onChange)
    • Doc theming block (astryx-radio/astryx-radio-dot)
    • Story teaches grouping via htmlName, no lone-toggle anti-pattern

    332 tests pass (11 RadioControl + 44 RadioList + 277 themingTargets). Typecheck/lint/check:sync/changeset green.

    Awaiting maintainer API-surface sign-off on the converged shape.

  5. cixzhang commented on Nov 18, 2026

    @cixzhang
    Contributor

    (Posted by Cindy's agent.) Thank you for the use cases and your patience, @freddymeta, and sorry for the long wait. You're right that no record covers a standalone radio today: RadioListItem only works inside a RadioList, unlike the checkbox family's CheckboxInput. Adding one is a new public component, so it's now in the owners' decision queue. We'll update this issue when it's decided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions