Repository navigation
Description
Indicators — componentized, themeable selection visuals
Tracking issue for the indicator layer landing in #4712.
A checkbox's box, a radio's circle, and the mark beside a chosen row are stateful
visuals, not glyphs. They have unchecked / checked / mixed states, they tint when
the row around them is hovered, and a theme may want to swap one for another
entirely. The earlier attempt modeled them as theme-supplied render functions
(controlIcons), which fought the system three ways — inline styles outrank every
layer of the cascade, function-valued theme fields don't survive astryx theme build, and hover/focus had nowhere to come from because that state is genuinely CSS
ancestor state. #4712 replaces that with components: CheckboxIndicator /
RadioIndicator, a defineTheme({indicators}) registry, and a slot mapping so a
component's selection mark can be pointed at a different indicator.
Three goals, all met by the PR:
- Theme them — an indicator renders stable class targets, so
components: {checkbox, radio, radio-dot}reaches it like any other component. Replacement is
the second, heavier level. - Use the radio control in a selector, per theme —
componentIndicators: {'selector-selected-option': 'radio'}. Confirmed in a browser: all options render
a radio, exactly one checked, unselected options draw an empty circle. - Swap the selection indicator generally — any indicator into any
indicator-capable slot, including a theme's own component.
Vibe test results
Ran an API-arbitration vibe test on the one decision that was still open: what the
state values should be called. Test lives at
internal/vibe-tests/indicator-state-test/ (PLAN.md, prompts.json, four variant
docs, RESULTS.md).
Method. 4 conditions × 4 prompts = 16 generations, claude-sonnet-5 at fixed
effort. One isolated sub-agent per cell, spawned with no node attached — no
filesystem, no network, so a generator could not reach the repo, the real API, or
another condition's doc. Prompts describe UX only; verified beforehand that no prompt
and no variant doc contained another condition's value words (this caught three
leaks — "fully on or fully off", "turn off", "when on… when off" — all rewritten).
| Condition | state values |
|---|---|
A-onoff |
off / on / partial |
B-selection |
unselected / selected / partial |
C-native (control) |
unchecked / checked / indeterminate |
D-elided (probe) |
values removed — the doc asks the author to name them |
1. The third value is mixed, unanimously — and it isn't partial
D-elided is the read: whatever it invents is the unprimed mental model.
| Prompt | resting | engaged | third |
|---|---|---|---|
ind-2 file list |
unchecked |
checked |
mixed |
ind-4 brand tick box |
off |
on |
mixed |
ind-8 folder tree |
unselected |
selected |
mixed |
The binary pair is a three-way tie, one vote each — no data-driven winner, so it
should be tie-broken on other grounds rather than argued.
The third value is mixed 3/3. partial scored 0/3 — it was our invention and
nobody reached for it. mixed is also the ARIA token, and a C-native run
independently wrote aria-checked={isIndeterminate ? 'mixed' : allChecked} while its
own doc said indeterminate — arriving at the same word from the a11y side.
2. Unplanned: the enum does not stay internal
We designed state as an indicator-authoring detail. Generators put it on the
consuming component's public API:
<Checkbox state="off" | "on" | "partial" /> // A
<Checkbox state="unchecked" | "checked" | "indeterminate" /> // COne even noted it chose this "rather than inventing an unrelated
checked/indeterminate boolean pair" — the indicator vocabulary displaced the
conventional control API. Whatever we pick gets mirrored onto public props. That is
the argument against on/off: Astryx ships a real Switch, and
<Checkbox state="on"> reads like one.
3. Draws-in-every-state — 4/4 pass
The highest-severity risk: an indicator that renders only when selected leaves blank
rows and silently breaks every themed radio. All four conditions produced the
declarative mapping unchanged and nobody hand-rolled a conditional mark — because
the mapping is declarative, there is nothing to get wrong. An argument for keeping
the slot API declarative rather than exposing a lower-level "render the mark
yourself" seam.
4. Replacement contract — 4/4 pass on the three that matter
aria-hidden 4/4 · renders children (the busy-spinner path) 4/4 · does not
draw its own focus ring 4/4.
Worth stating plainly: these are the exact three mistakes made by hand in #4712 —
the first draft moved the focus ring into the indicator, and both shipped example
replacements ignored children. Four of four generations got them right when the doc
stated each in one sentence. The contract is teachable; it just has to be said.
5. Tokens — 4/4 fail
Every replacement invented CSS custom properties that don't exist — --radius-md,
--radius-sm, --color-brand, --color-on-brand, --color-positive-muted,
--color-border — and every one flagged it: "wished the doc had told me the full
set of available tokens." Invented tokens are a blocking-criteria violation here.
6. The dominant gap: no consuming component, no theme application
Flagged by every run. The doc describes the indicator but never the component
that hosts it, nor how a defined theme is applied. 4/4 invented a Dropdown; others
invented <Checkbox state=…> or fell back to a raw <input type="checkbox"> with
imperative ref.current.indeterminate. <Theme theme={…}> (correct),
<Theme name="brand">, and <ThemeProvider> were all guessed — the doc imports
Theme and never uses it once.
Two runs declined to invent a component and hand-rolled native inputs, which is the
worst outcome available: docs that push a generator out of the design system. This
is a bigger lever on output quality than the naming question we ran the test for.
7. Expand/collapse indicators — the need is real, the vocabulary is untested
ind-8 put open/shut and ticked/mixed on the same row. No collision occurred — but
only because 4/4 hand-rolled the expand affordance as a <button> with ▸/▾
glyphs. Nobody attempted to use an indicator for it, because none is documented.
Two conclusions of different strength, and the difference matters:
- Well supported: the need to swap expand/collapse indicators is real. Given a
disclosure control and an indicator system, a generator hand-rolls the disclosure
every time. Multiple teams have asked to customize the expand/collapse toggle on
selectors and menus; this is the same gap seen from the generation side. - Now measured — see round 2 below. The two prompts designed to test the
vocabulary question (ind-6, a chevron swap;ind-8, both families on one row)
were not run in round 1, so that conclusion was asserted rather than measured.
Round 2 corrects it.
Round 2 — cross-family, measured
Two more conditions, whose docs both document expand indicators
(expandStart / expandEnd) alongside selection. 580 words each, differing only in
vocabulary: E-shared uses off/on/mixed for selection and off/on for
expand ("the same vocabulary every indicator uses"); F-perfamily uses
unchecked/checked/mixed and collapsed/expanded.
The shared vocabulary did not stay shared. ind-8 / E-shared was handed one
vocabulary for both families and immediately declared two types anyway:
type SelectionState = 'off' | 'on' | 'mixed';
type ExpandState = 'off' | 'on';Given a single enum, the generator re-derived the split on its own, because the state
spaces genuinely differ. Sharing the value names bought nothing — it just made two
distinct types share overlapping strings, so state="mixed" would typecheck on a
chevron.
Shared vocabulary collides with ARIA at the call site. ind-6 / E-shared wrote
on adjacent lines:
aria-expanded={isOpen}
<Indicators.expandStart state={isOpen ? 'on' : 'off'} />One boolean, two vocabularies. F-perfamily's equivalent reads
state={isOpen ? 'expanded' : 'collapsed'}, matching the aria-expanded beside it.
Same leak as finding 2, observed in the disclosure family.
Decisions
- Rename the third state
partial→mixed(3/3 unprimed, matches ARIA). - Keep
unchecked/checkedfor the binary pair — thearia-checked
vocabulary, which spans every selection control we have (checkbox, radio,
menuitemcheckbox,menuitemradio, selected listbox option) and survives being
mirrored onto public props per finding 2. - Adopt per-family vocabularies drawn from ARIA — selection follows
aria-checked(unchecked/checked/mixed), expand followsaria-expanded
(collapsed/expanded). Measured in round 2, not assumed. - Per-family typing follows from that. A flat
IndicatorPropswith a widened
union would let a chevron accept'mixed'and a checkbox accept'expanded'.
The state space belongs to the family, soIndicatorPropsshould be
parameterized by it, with the registry and slot map as family-checked mapped
types — which turns "map a slot to any indicator of the same family" from a doc
sentence into a type rule.IndicatorProps<F = 'selection'>is backward
compatible with what feat(theme): add themeable indicators #4712 ships, so the parameter can land with the expand
family. What must not ship is a widened flat union spanning both families. - Name the tokens a replacement should use, in the indicator docs (finding 5).
- Show the owning component and
<Theme>in use, in the indicator docs
(finding 6).
Follow-ups (not in #4712)
-
componentIndicatorsas a map parallel toicons, and make the check glyph an
icon-backed indicator so everything in a selection slot has one shape. Keep the
resolution seam internal — it has one call site, and one data point is thin
evidence for a permanent public name. -
expandStart/expandEndindicators, so disclosure affordances are swappable
the same way selection marks are. Two, not one: a start-side chevron points along
the text direction and mirrors under RTL (TreeListItem,rotate(90deg)), while
an end-side chevron points down and does not (Selector,rotate(180deg)).
Noteastryx-selector-indicator-iconalready carriesstate: expanded | collapsedtoday, so this formalizes an existing surface rather than inventing
one. -
IndicatorMapmodule augmentation currently hands back a typedundefinedat
runtime for a name with no default. Make it safe, or close the map. -
Indicator.doc.mjs— the directory has no doc file, sothemingTargets.test.ts
skips it andnpx astryx componentcan't see the new components. - A Selector-level test asserting the
{indicator: 'radio'}path renders a radio
on every option with exactly one checked.
Activity
fix(indicator): guarantee the focus ring; rename targets non-breakingly
feat(theme): add themeable indicators
fix(indicator): guarantee the focus ring; rename targets non-breakingly