Headless APG widgets on Solid 2 (solid-js + @solidjs/web 2.0.0-rc.13): state plus attribute objects, no elements, no styling. Each primitive is conformance-checked against its Quint spec (packages/apg-specs/specs/apg/<pattern>.qnt) and the ported scenarios (packages/apg-specs/scenarios/apg/<pattern>.*.json).
const disclosure = createDisclosure({ defaultValue: false });
<button {...disclosure.triggerProps}>Details</button>
<div {...disclosure.panelProps}>…</div>Where the platform has the element, render it and let it own the behaviour: details, dialog, meter, native
inputs, focusgroup. The mapping — the code, what the platform takes over, and the gaps that keep the primitive —
is docs/hosts.md.
createDisclosure is plain Solid signals. The generated Quint model is not loaded at runtime; it is the oracle in tests:
specDriver) and on the real DOM (domDriver);differentialWalk feeds seeded random steps to both and compares aria/hidden/focus/callbacks after every step.Why: the machine adds Effect + a model evaluator to every consumer's bundle and forces a signal bridge, while the differential walk catches the same drift (mutation-checked: dropping the change callback of a controlled request fails 11 tests).
specs/apg/<pattern>.qnt + generate:all specs/apg/<pattern>.qnt + spec-only test (see packages/apg-specs/test/apg/disclosure.test.ts).packages/apg-specs/src/apg/<pattern>.bridge.ts: a SpecBridge (scenario vocabulary <-> spec events/state), a <pattern>Config normalizer that throws Unsupported for config you do not model, <pattern>Steps (random-walk alphabet), <pattern>Probe.src/<pattern>.ts primitive; test/<pattern>.fixture.tsx renders parts with data-part="<name>" and returns a Mounted; test/<pattern>.browser.test.tsx runs scenarios + differentialWalk (copy disclosure.browser.test.tsx).DIVERGENCES with a reason; the test requires it to still fail.Conventions: visible lists the hideable content parts only; boolean attributes read "true" when present; key/type on a target focuses it first, and a key whose target is the widget's owner (menu, grid) is pressed on the part the primitive says is focused; data-* attributes are library styling hooks (Unsupported); aria-controls-style references read back as part targets.
The walk's focus observation is Mounted.focus() — the part the primitive itself considers focused (trigger,
menuitem:2, null for outside). document.activeElement is not the observation: a page that mirrors the
primitive's state into DOM focus (which is what a host does, see docs/hosts.md) has the mirror's focus event delivered
by the browser when it gets round to it, not when focus() returns.
Why that matters, measured (bean cssints-6fau): the menu fixture mirrored focusLevel/focusIndex in a createEffect.
The primitive's item props take onFocus as the platform's word on where focus is (setFocusItem), so the mirror fed
back into the primitive. In a page that is not the focused one — a background test page, a window that just lost focus —
the browser delivers that focus event one task (or several) later, and by then the primitive has moved on: the event
rewinds it to the item the fixture focused a step or two ago. Instrumented over 4 800 walk steps, 795 of 795 adopted
focus events were stale (the focused item was not the primitive's item). That is what a walk reports as a divergence the
model never produced. It cannot be waited out (a longer settle widens the window), retried (the rewind repeats), or
guarded (a suppression flag set around focus() is cleared before the browser dispatches).
So the contract is:
setProp, and returns Mounted
with a focus() that maps the primitive's focus to a part name;createEffect that mirrors state into DOM focus. If it needs one for a real-page path,
guard it on that path: menu.fixture.tsx keeps its sync for provider: "auto" (the native engine, where no walk runs)
and leaves the polyfill path, which the walks force, alone;key/type step focuses its target, and when the target is the
widget's owner (menu, grid) it focuses the part the primitive reports instead, because that is where a user's focus
would be and where the platform's own key handling looks.A walk's inputs are one step at a time, and each step must be the only input. Three things enforce that:
ArrowUp/ArrowDown/Home/End change
focusLevel/focusIndex in the primitive's own key handler (menu.ts, by the rule the spec models: wrap, ends), and
preventDefault keeps the provider from moving a second time. onFocus stays the platform's word for focus that
arrives from outside the widget — Tab into it, a click — which is what it is for. The native engine is unchanged:
there the platform owns the block axis and onFocus is how its moves arrive.tabindex="0" on the row it says is focused (and focusgroupstart,
which both providers read) after every settle, so a probe of the roving stop reads the state and not whatever the DOM's
focus last was. The native engine writes no tabindex at all — its focus controller owns the stop — so there the
author's markup stands.mouseover/mouseenter nobody asked for — a menu that focuses on hover jumps to that row, a toast's countdown
pauses and never resumes. The driver stops pointer events at the widget unless the step is a pointer step, and
test/setup.browser.ts parks the pointer on a fixed 1 px corner element between tests.Measured (bean cssints-6fau): before this, the checkable fixture adopted 795 stale focus events in 4 800 walk steps
(the DOM focus was almost never where the primitive was, and every adopted event pulled the primitive to it). After,
the walks take no focus input at all, and packages/headless's suite went from about one failing run in three to five
consecutive green runs, including two runs under doubled load.
Every props object a primitive returns carries data-part: the name that part goes by in the primitive's own vocabulary. It is additive — no behaviour, no new option, no ARIA — and it exists because the props are the only stable styling contract a consumer has, so a skin can write [data-part="trigger"] once instead of asking every host for a class name.
The value is typed string, not a literal, so the host may replace it, and a fixture that must address one instance renames it after the spread: <div {...canvas.nodeProps(id)} data-part={node${id}}>. Where a part is not an element of its own (TabRenameProps is the rename controller: onDblClick, begin, commit, cancel), there is no marker.
| primitive | parts |
|---|---|
| accordion | heading trigger panel |
| alert | alert close |
| alertdialog | trigger dialog backdrop cancel confirm save input |
| breadcrumb | nav breadcrumb item link |
| button | button |
| canvas | viewport layer node live |
| carousel | carousel rotation prev next slide tablist tab |
| checkbox | checkbox |
| checkbox-group | group checkbox (the parent and each child) |
| combobox | input trigger popup |
| command-palette | input list option empty status dialog backdrop title |
| confirm | trigger dialog backdrop title description cancel confirm |
| date-picker | status trigger popover title previous next grid weekday cell |
| diagram | node edge status |
| dialog-modal | trigger dialog (polyfill and native) backdrop dismiss |
| disclosure | trigger panel |
| drawer | trigger backdrop content handle |
| dropzone | input zone browse status |
| feed | feed article before-feed after-feed |
| field | control label hint error |
| filterable-menu | trigger input menu group group-label item item (a submenu trigger is a row) submenu empty status clear dialog backdrop title |
| grid | grid row cell widget header |
| knob | knob value |
| link | link |
| listbox | listbox option |
| listbox-rearrangeable | list option |
| menu | trigger menu menuitem |
| menubar | menubar menuitem menu submenu |
| meter | meter |
| pagination | nav list item link previous next status |
| panzoom | viewport image value |
| player | surface play seek mute fullscreen |
| popover | trigger content |
| radio | radiogroup radio |
| resizable-panels | group pane separator |
| scrollprogress | bar |
| scrollspy | nav list item link |
| slider | thumb track |
| slider-multithumb | thumb track |
| spinbutton | input increment decrement |
| status | status |
| switch | switch |
| table | table row-group caption header-cell header row cell select-all checkbox |
| tabs | tablist tab tabpanel close input |
| textbox | input (also textarea, createTextArea) |
| timeline | timeline row ruler list bar label |
| toast | region toast |
| toolbar | toolbar item |
| tooltip | trigger tooltip |
| treegrid | grid row cell expander |
| treeview | tree item |
| view-transition | view-transition (both persist and name) |
| virtual | scroll item spacer |
| windowsplitter | primary secondary separator |
test/parts.test.ts fails a primitive whose props type omits the marker, whose inline props type omits it, or that names a part "".
When a ported scenario and the primitive disagree, decide it this way:
A scenario whose expectation we deliberately do not meet stays a negative test: it goes in the primitive's DIVERGENCES map with its reason, and the test requires it to still fail, so the gap cannot silently close. skipped is different — an Unsupported config or step the bridge cannot express at all, not a divergence. See packages/apg-specs/scenarios/apg/README.md.
State is one machine with a request vs commit split . An event a user would see as a change is a request carrying the intent; the host either accepts it (uncontrolled — the common case, auto-commit) or the controlled value prop is the only thing that changes state.
Two invariants: a rejected request leaves state untouched, and in controlled mode no event commits. Uncontrolled is the degenerate case where every request is accepted, so one spec covers both.
Primitive API (the React/Solid convention): value + onValueChange (a request the host may ignore) for controlled, defaultValue for uncontrolled.
A list that arrives later is still one widget. The options that are lists — createListbox's items, createTable's rows, createRadioGroup's values, createTimeline's rows — also take a getter (() => list()), and it is read at attribute-read time. So an async fetch, a filter or a trace that lands after mount changes the list without rebuilding the primitive, and the active option, the selection and the roving tab stop survive. A host that rebuilt the widget inside a memo lost exactly that (the feedback from adopting 0.20.0, bean cssints-65eb).
Implemented for disclosure (reference: specs/apg/disclosure.qnt, src/disclosure.ts) and player (the four preferences volume / muted / rate / fullscreen; transport stays adapter-driven). The shared core is src/controllable.ts (createControllable): value + initial + onChange in, [current, request] out.
Template for every other pattern. A pattern adds, in this order:
var controlled: bool (+ var accepting: bool, a controlled host that writes every intent back) and var valueProp (the controlled value, meaningful while controlled), set by configuration events (init is literal-only): control (adopts the current value) and acceptRequests.requested), bumps a requests counter when the intent differs from the current value, sets outcome ("accepted" uncontrolled or accepting host, "rejected" controlled and holding) and base (the value on arrival), and commits only through landed(holds, current, want). Add setValue (nondet) / hostToggle: the host writing the value, the only commit while controlled, resetting outcome to "none".ControlledFollowsProp (controlled => value == valueProp: no event commits), RejectedRequestUntouched (outcome == "rejected" => value == base), AcceptedRequestCommits (outcome == "accepted" => value == requested), each with a hand-built bad state in the spec test.<pattern>Config maps controlled (and a pinned value, expanded, meaning a host that rejects) to { controlled, accepts }; setup emits control / acceptRequests / setValue; events reads the requests counter and the requested payload; add the host steps to <pattern>Steps and the probe.value + onValueChange (a request the host may ignore) for controlled, defaultValue for uncontrolled, built on createControllable; programmatic methods are requests; value is T | undefined (exactOptionalPropertyTypes). The fixture is the host: a signal passed as value, written back only when accepts.DIVERGENCES.Generator limits met and worked around (no parameterized actions, no let): a request action spells landed(...) out per assignment; every action assigns every var.
snapshot() and act()A demo, a test or an agent should not have to synthesise a keydown to move a widget. Two primitives carry it so far:
createRadioGroup and createListbox. snapshot() is the observable state as JSON — the checked and focused radios (or
the selection and the active option), the disabled ones, the count, the flavor or selection mode — and act() takes the
intents the keyboard and the pointer already speak: next / previous / first / last (on the radio, focus moves and
checks what it lands on: the pattern's selection-follows-focus), focus, and check on a radio, activate (Space),
type (type-ahead) and click on a list. An intent goes through the primitive's own paths, so the request/commit split,
the callbacks and the ARIA are the same as a key's.
The one difference is the moves: a radio group moves by state (the host's effect puts DOM focus where the state says), so
act never touches the DOM; a listbox's whole model is "focus is the move", so its act({ type: "next" }) focuses the next
enabled option's element and the state follows the focusin, exactly as the platform's arrow does — the host must have
rendered the option.
The snapshot is JSON and nothing else: every field is what an ARIA attribute already says, so it cannot drift from what a screen reader hears. Read it after a flush — Solid 2 applies a write on the microtask — which is what a browser test does and what an MCP tool would do between two messages.
A primitive that has a seam honours an optional prefs entry (a Partial<Prefs>, src/prefs.ts). The host resolves its preferences and injects the values; @cssints/headless depends on solid-js only and never imports a preferences store — Prefs is a structural type, and an absent pref keeps today's behaviour.
motion (the internal reduced-motion default, unless the explicit reducedMotion option is set), focusFollowsCamera (off: focus still moves the cursor, but the camera does not pan to centre), announce (off: the live region stays empty while onSelectionChange still fires).tooltipShowDelayMs / tooltipHideDelayMs, exposed as showDelayMs() / hideDelayMs() for the host to wire its setTimeout from (the spec keeps timers as events).motion (reduce: the update runs and no transition starts; the same path as a browser without the API).Everything else ignores prefs: accordion, alert, alertdialog, breadcrumb, button, carousel, checkbox, checkbox-group, combobox, command-palette, confirm, dialog-modal, disclosure, feed, field, grid, link, listbox, meter, panzoom, player, popover, radio, resizable-panels, slider, slider-multithumb, spinbutton, switch, table, tabs, timeline, toolbar, treegrid, treeview, windowsplitter — they expose no timing / motion / live-region / camera seam. listbox / treeview / timeline typeahead timeouts are host-driven via their reset methods, so they take no delay here either.
motionDurationMs is not consumed: canvas tweens are tick-driven, not millisecond-driven, and the look layer owns durations. It stays in Prefs only so a host's preference record fits the type.
The physical side of a gesture is output, not state. Nothing about a detent being felt changes what a widget is, so it is not a primitive, not a spec and not a provider/context: @cssints/headless takes options in and returns props out, and a <Haptics> provider would be exactly the ambient state every primitive here was written to avoid. The primitives with physical semantics — knob, slider, slider-multithumb, spinbutton, switch, checkbox (and checkbox-group, once for its children) — take one option, the same name and shape on every one of them:
export type FeedbackIntent = "detent" | "latch" | "release" | "limit";
export interface Feedback {
/** The vibration channel; the host maps an intent to `navigator.vibrate(...)`, or to nothing. */
readonly haptic?: (intent: FeedbackIntent) => void;
/** The sound channel: the same intents, for a click sample or a beep. */
readonly sound?: (intent: FeedbackIntent) => void;
}feedback?: Feedback — both channels optional, both called with the same intent, and nothing is called when the host passes neither. It is read lazily, so a host that flips its "haptics off" preference does not rebuild the widget.
Named intents, never milliseconds, never the platform. The string union is the whole contract. navigator.vibrate is missing entirely on iOS Safari and inert in a background tab, so a primitive that promised a haptic would lie on half the targets; the host decides what "detent" is (navigator.vibrate(8), a click sample, nothing), and its off switch belongs next to announce in its preferences, not in a primitive. The pattern and the sample are the skin's or the app's.
| intent | when it fires |
|---|---|
detent |
a user interaction crossed a step: a drag landed on a new value, a wheel notch (knob), an arrow / PageUp / PageDown key, a stepper button |
latch |
a two-state control turned on — switch, checkbox, a box in a checkbox-group (a mixed box checks, so it latches; the group's controller latches only when every box ends up on) |
release |
that control turned off |
limit |
a user interaction hit a bound (min, max, the neighbouring thumb) and could move no further |
No intent on focus, on a programmatic change (setValue, setChecked, setValues, setChildren, stepBy), or when the host writes value. A press that jumps several steps is one detent: the tick marks where the thumb landed, not every step it crossed.
One limit per interaction, not one per frame. A held arrow key, a wheel still spinning and a pointer pressed against the end all arrive many times a second, and a tick each is a buzz. The primitive emits the first limit and stops until something moves the value or a new interaction starts — a fresh key press or pointer press against the same bound ticks again.
A vetoed request still ticks once. The intent is issued with the request the user made. The primitive cannot see a controlled host's veto without a frame of delay, and a late tick is worse than a missing one, so a host that refuses changes gates feedback itself (the same gate as "haptics off").
checkbox-group: pass feedback to the group, not to each box. The group reports for its children — a kit Checkbox inside a group asks the group to click — so one activation is one intent instead of two.
createCanvas is a headless viewport: the host renders the DOM, the primitive owns the camera, the gesture machine, the focus contract and the state. Its behaviour is packages/apg-specs/specs/canvas/{camera,pointer}.qnt, and the DOM is checked against it by the differential walk.
The handle. nodes sets the initial geometry; everything after that is pushed in, because a node's position, size and paint order belong to the host:
setGeometry(patches) — position and/or size of existing nodes, in any mode. Clamped into the world bound, and a running drag or marquee re-solves against the new geometry.setOrder(ids) — paint order, bottom first. This is the z-index and the hit priority.addNodes(nodes) / removeNodes(ids) — membership. Adding puts nodes on top; removing drops ids from the selection, clears the cursor / editing if they held one, and closes the z-order up. Survivors keep their DOM id, selection and focus.Membership, sizes and z-order are not modelled in pointer.qnt (its node set is fixed at three): the spec owns the camera, the gesture machine and the selection, the host owns the geometry. Bad input to any of these throws before anything changes.
Coordinates. screenToWorld(point) and worldToScreen(point) convert between viewport px and whole world units against the live camera — a running tween's current frame, not its target — so a host may call them at any time. That is what the pointer pipeline does not cover: drawing a remote cursor where a collaborator's point is, anchoring an overlay to a world position, or hit-testing a drop target the pointer never reached.
Culling is the host's job. isCulled(id) means a node is off screen and not selected / focused / editing. The host drops that node's body and keeps its shell — role, accessible name, tab stop — so culling never costs a tab stop. The shell's content-visibility: auto is a free extra, not the mechanism: its skip distance grows with zoom, so it skips almost nothing at 16x.
Snapping is snapCandidates({ axis, value, id, width, height }) => readonly number[], whole world units, defaulting to the 50-unit grid. value is the dragged node's origin, so right-edge alignment is target - width. The 8 screen px threshold and "nearest candidate, ties to the larger" are the primitive's; the candidate policy is the host's.
The landing preview is the host's to draw. While a pointer drag runs, state().landing is the origin the release would commit — { id, x, y } in whole world units, already snapped and clamped into the world bound — or null when no drag runs. With snapping off it follows the pointer off the grid. The primitive renders no elements, so a host marks the slot with a ghost of its own; the release commits exactly there. state().drop then describes the correction for TWEEN_TICKS frames (from the origin the drag rendered, to the committed one, which position(id) already reads) when a host wants to animate it. In the ordinary drag from and to are equal — the live drag already renders the snapped slot — so the drop starts no frames; a clamp into the world bound is the case that differs. Reduced motion never starts one. Keyboard moves are untouched: one grid step and an announcement. The landing and the drop are derived from pointer.qnt (landingX / landingY, LandingIsTheSnappedOrigin); the animation is presentation and stays out of the spec, like the camera's easing.
Editing is split. The host renders its editor inside the node (tabindex="-1", user-select: text) and focuses it when state().editing is that node. The primitive owns the rest: it ignores a composing keydown, ends editing when focus leaves the node (so native Tab continues in spatial order), sets user-select: none on the layer, and puts focus back on the node on Escape / F2.
Nested canvases are two instances the host composes: a #canvas node holds a second createCanvas, and the inner viewport stops propagation of its own pointer, wheel and key events. The innermost canvas under the pointer owns the event, so a press or zoom inside it never starts an outer gesture or moves the outer camera. A nested canvas is a single tab stop in its parent.
createPanZoom is one image fitted to a viewport: the scale, the offset and the prop objects for the viewport, the image and a live value. There is no APG pattern for pan-zoom, so there is no Quint spec and no ported scenarios: the contract is this module's own and test/panzoom.browser.test.tsx is its oracle. The case it replaces (kocharin-art-3's Zoomable: ~110 lines of pointer maths) had no keyboard path and no ARIA at all.
The accessible contract is three parts, and the pointer is a bonus: a viewport that takes focus (role=group, tabindex=0, aria-roledescription="zoomable image", aria-describedby the value), keyboard operations that stand in for every gesture (+ / = / - zoom by step, arrows pan by 24 px, Shift ×4, 0 resets), and a polite live region (role=status, aria-live=polite, the current "150%"). valueProps deliberately carries no hidden: a hidden live region is not announced, so the host hides it visually.
Not createCanvas. The canvas is a camera over an infinite world with nodes, culling, snap and a z-order; a picture is one image in a box. There is no world, no node set and no reason to carry the camera machine.
const panzoom = createPanZoom({ min: 1, max: 4, step: 0.25 });
<div {...panzoom.viewportProps} class="viewport">
<img {...panzoom.imageProps} src={src} alt={alt} />
<span {...panzoom.valueProps} class="visually-hidden">
{panzoom.value()}
</span>
</div>;Gestures. A drag pans, a second pointer pinches about its midpoint, a double click resets. Pinch is two pointers and the distance between them, not a platform gesture, so it works where PointerEvent does. Wheel is zoom only with ctrl / meta — the browser's own pinch arrives as ctrl+wheel — and a bare wheel is never preventDefaulted, so the page keeps scrolling; a swallowed wheel is the one thing that is never acceptable on a trackpad.
A host can pan without a pointer. panBy(dx, dy) moves the offset by a relative step through the same bounded move a drag takes, and reports it with onPanChange; the kit's Panzoom runs the glide after a flick on it (the machine is the skin's, the momentum is not this primitive's).
bounds: "clamp" (the default) bounds the offset by half the viewport's scaled overflow, so the image is expected to fill the viewport at min (width: 100%; height: 100% / object-fit: cover). A letterboxed image smaller than its viewport cannot be held gap-free: give it a viewport of its own or bounds: "free".
Left to the host: the box (the viewport's size and overflow: hidden, touch-action: none if a touch drag should pan), the look (a transition on the transform, transform-origin: 50% 50% — the default this maths assumes), and the image itself. Not modelled: rotation, and a keyboard pan at scale min (the clamp means there is nothing to pan, so the arrows are inert). Inertia is the host's too: panBy is the seam a glide after a flick drives, so the momentum's curve and its motion preference stay with the skin.
const panzoom = createPanZoom({
scale, // controlled: the host owns the scale
onScaleChange: setScale,
onPanChange: (offset) => save({ x: offset.x, y: offset.y }),
});Controlled is scale + onScaleChange; the offset has no controlled prop, so a host that ignores a scale request also gets the offset resolved for the scale it refused.
createViewTransition is a runner around document.startViewTransition (Baseline October 2025): it runs an update exactly once, starts a transition around it when the platform can, and treats a skipped transition as a successful run. There is no APG pattern, so there are no APG scenarios; the primitive's behaviour is packages/apg-specs/specs/patterns/view-transition.qnt, and the DOM is checked against it by the differential walk.
const viewTransition = createViewTransition();
await viewTransition.run(() => setSelection(next));
<img {...viewTransition.persist({ class: "card" })} />;persist() is the default case: the same element persists across the update. It returns { style } with view-transition-name: match-element, so the browser assigns the unique name itself and the host keeps no bookkeeping. Use it for the element that moves, resizes, or is re-rendered in place — the case a host reaches for first.
name(id) is the morph pair: one element leaves, another arrives. It returns a deterministic prefixed name (vt-<id>, the prefix is the prefix option) plus the optional view-transition-class hook, and leaves the pair's rule to the host. The platform rule the primitive cannot enforce: only one element may be rendered with that name at a time. MDN states it plainly — "If two rendered elements have the same view-transition-name at the same time, the ViewTransition.ready Promise will reject and the transition will be skipped." The whole transition is skipped, silently, not just the pair; that is why persist() needs no names and a per-item name() needs the host to render one of the pair.
Reduced motion is the inert path. With prefs.motion === "reduce" — and, identically, in a browser without the API — run awaits the update and starts nothing, and supported() reads the live API (false during SSR). The pref is read on every run, so a host may pass a getter. A transition the platform skips resolves run instead of rejecting it: the update already ran, so a skip is not a failure.
Latest wins. A second run while one is active starts a new transition; the platform skips the running one. There is no queue and the primitive calls no skipTransition() — that is the platform's own policy. state() reports { supported, active }; neither it nor the style objects touch the DOM.
Left to the host: the transition's look (durations, easing, the ::view-transition-* pseudo-elements), cross-document transitions (pageswap / pagereveal plus @view-transition { navigation: auto }, CSS only), view-transition-class styling and types. Not modelled: name allocation across rendered elements — the spec covers one transition at a time, the host owns uniqueness.
createKnob is a virtual knob after GarageBand's (How Apple Designs a Virtual Knob): one focusable control you spin around its centre or slide vertically / horizontally, with one gesture locked per drag. There is no APG pattern and no ARIA role for a dial, so it is a role=slider with aria-valuenow / aria-valuetext, and test/knob.browser.test.tsx (real Chromium) is its oracle — there is no Quint spec.
const knob = createKnob({ labels: { knob: "Volume" }, format: (value) => `${value}%` });
const turn = () => knob.percentOf(knob.value());
<div {...knob.knobProps} class="knob">
<span class="indicator" style={{ transform: `rotate(${turn() * 360}deg)` }} />
</div>
<span {...knob.valueProps} class="visually-hidden">
{knob.value()}
</span>;percentOf is the fraction of a full turn the skin rotates by; the look is the host's. valueProps must be rendered (hide it visually, never with hidden): it is the live announcement.
A dial is never the only control. The keyboard contract stands in for every gesture — arrows step, PageUp/PageDown by ten steps, Home/End to the bounds — but a numeric field (createSpinbutton) still belongs next to it: a slider role is operable but does not make a range easy to discover or type.
Gestures (gesture, default "both"). A pointerdown records the centre, the start angle and the side. On the first movement past 6 px the drag picks a mode once and keeps it for the rest of the drag: movement that stays on one axis (the other under 35% of it) is a slide, anything else is a turn around the centre. The reference's direction rule holds: down on the right half turns clockwise (up in value), down on the left half counter-clockwise, and a horizontal slide uses the same left/right side. A spin's value per degree shrinks as the pointer moves away from the centre — the same angle is a longer arc, so farther is finer. gesture: "spin" / "slide" disables the other. The wheel steps once per event and preventDefaults, so hovering the dial stops the page from scrolling.
wrap makes the dial continuous: past max comes back at min, so a full turn is a full cycle instead of the clamped end of the range. setValue / stepBy are requests like a key, so a controlled value still owns the result.
createResizablePanels is a group of N panes and N-1 separators: react-resizable-panels' layout on the APG window splitter's keyboard. Its behaviour is packages/apg-specs/specs/patterns/resizable-panels.qnt — not an APG pattern, so it lives under patterns/ — and the DOM is checked against it by the differential walk. The spec is the three-pane instance (10/80 bounds, 10% steps, pane 0 collapsible at 0); the primitive takes N panes and any bounds.
The contract. Sizes are percentages of the group and always sum to 100. Each pane has min / max; a collapsible pane sits at collapsedSize (0) while collapsed. A move — an arrow, Home/End, a drag — changes only the two panes around the separator, clamped by both bounds. Collapsing hands the pane's space to the nearest pane that can take it and cascades outward; restoring takes it back in the same order, so a restore always returns the remembered size.
The separator is the widget: role=separator, tabindex=0, aria-orientation, aria-valuenow = the size of the pane it resizes, aria-valuemin / -max that pane's bounds, aria-controls it. Arrows move by step (10%), Home/End jump the pair to its bounds, Enter collapses and restores. A separator next to a collapsed pane is inert (only Enter restores).
The drag is snapshot + delta: pointerdown remembers the layout, every move re-solves from it, so dragging back past a clamp recovers exactly. It uses pointer capture and ends on pointerup / pointercancel; a host write of sizes ends it too. Keyboard input is a no-op while a drag runs.
snap is a learned magnet. Every release leaves a mark at the width it was dropped at; a mark's weight halves every five drags, the marks are counted on a half-percent grid, and the divider sticks to the tallest hill once about three recent drags stand under it. The point is sticky — a hill that stays inside its zone (10 px, off the group) leaves the point alone, so it cannot drift a pixel per drag. Inside the zone the edge lands on the point while the pointer keeps moving; hold Alt for the exact width, which keeps the widths beside the point reachable, and keyDown never snaps: the keys are exact by contract. snapPoint(index) is the learned width, for a skin that marks it. The marks are the whole state: onSnapMark(index, marks) hands a release's list to the host and snapMarks takes it back, so the habit survives a reload — the hills are rebuilt from the marks, and age is a count of drags, not of days, so a week away moves nothing. storageKey carries the layout; the marks are the host's.
const panels = createResizablePanels({
panes: [{ label: "Sidebar", collapsible: true }, { label: "Content" }, { label: "Inspector" }],
defaultSizes: [20, 40, 40],
storageKey: "app-layout",
onSizesChange: (sizes) => save(sizes), // ignored while uncontrolled
});
<div {...panels.groupProps} style={{ display: "flex" }}>
{[0, 1, 2].map((index) => (
<>
<div {...panels.paneProps(index)} style={{ flex: `${panels.sizes()[index]}%` }}>
…
</div>
{index < 2 && <div {...panels.separatorProps(index)} />}
</>
))}
</div>;Controlled is sizes + onSizesChange (the request), like every other primitive. A pane's
defaultSize is kept and the panes that name none share what is left equally; defaultSizes states the
whole start instead, and storageKey persists the layout in localStorage — host storage, so the key
belongs to the host's namespace. A group nests: the inner group's separators measure their own parent, so
a sidebar beside a stack of editor and terminal is two instances, and the outer drag never re-solves the
inner percentages.
Left to the host: pane bounds in pixels (percent only), and F6 (with three panes a Tab is enough). Not
modelled: react-resizable-panels' collapse-on-drag threshold (a pane collapses on Enter or a host write,
never by dragging through MIN) and restoring a pane that was mounted already collapsed (it returns to its
own min).
createField is the ARIA contract of a form field: a label, a control, a hint and an error. There is no APG pattern for it, so there is no Quint spec and no ported scenarios: the contract is WAI-ARIA (aria-describedby, aria-invalid, aria-required) and HTML (label[for], required), and where those are silent the majority of Base UI Field, react-aria TextField and ariakit FormControl. test/field.browser.test.tsx is its oracle (plain assertions on the attribute objects; no DOM is needed, the file name is only what vite.config.ts includes).
const field = createField({
required: true,
hint: "At least 8 characters",
get invalid() {
return touched() && password().length < 8;
},
get error() {
return "Too short";
},
});
<label {...field.labelProps}>Password</label>
<input type="password" {...field.controlProps} />
<p {...field.hintProps}>{field.hint()}</p>
<p {...field.errorProps}>{field.error()}</p>;<id>-control, -label, -hint, -error from id (or a unique one); labelProps.for is the control's id.hidden while absent, and aria-describedby lists only the ones that are shown, hint first: a reference never points at a hidden or missing id.aria-invalid only when invalid. An error message makes the field invalid; invalid: "message" is both the flag and the message (an error wins over it); invalid: true without a message marks the control and shows no error; invalid: false wins over everything, so a host can keep the message ready and pass touched() && failed().required sets both required and aria-required (a native control needs the first, a custom widget the second); use novalidate on the form if the browser's own bubbles are not wanted.errorProps.role is "alert" while the error is shown and undefined while it is hidden, so spreading errorProps is all the host does (no hand-written role={field.error() === undefined ? undefined : "alert"}); an element that is hidden announces nothing, and one that appears is announced. The hint stays a plain element: hintProps has no role.describedby is an id, or a list of ids, of an element the host owns, appended to aria-describedby after the field's own hint and error ids (password-hint password-error form-error) and dropped when empty. Give a form-level error ("The passwords do not match") one element with its own id and role, and pass that id to both fields: each control then names the same message, and it is announced once, not once per field. The field cannot see whether that element is shown, so pass the id only while it is (a getter: get describedby() { return mismatch() ? "form-error" : undefined; }); describedIds() includes it.undefined typecheck. id, required, invalid, hint, error and describedby are all T | undefined, so a getter over an optional prop (get required() { return props.required; }) compiles under exactOptionalPropertyTypes.createTextInput and createTextArea are createField plus the props a host forgets. There is no APG pattern for text editing — an <input> already is the pattern — so there is no Quint spec: test/textbox.browser.test.tsx asserts the attribute objects and the element behaviour.
const email = createTextInput({ type: "email", autoComplete: "email", inputMode: "email", required: true });
<label {...email.labelProps}>Email</label>
<input {...email.controlProps} />aria-describedby, aria-invalid only when invalid, role="alert" on a shown error.type, autoComplete (the HTML token list — the browser's autofill is the accessible path), spellCheck, autoCapitalize, inputMode, maxLength, readOnly, disabled, required, name, dir, placeholder, onValueChange (one callback for input).maxLength is the browser's. The primitive emits the attribute and reports the value it is given; it does not truncate in JS, because that breaks paste and IME.disabled vs readOnly. Disabled is out of the tab order and not submitted; readOnly is focusable, selectable and submitted. A field the user must read before signing is readOnly, not disabled.createTextArea adds rows, wrap and resize (resize is a style, since CSS has no attribute for it; none is what a layout that owns its own height wants).createDropZone is a file drop target on a hidden native <input type="file">: the picker, the accept filter and multiple are the platform's, and the primitive adds a drag target, the validation and a status line. There is no APG pattern for a drop zone; the drag state and the last delivery still change over time, so they have a machine (specs/patterns/dropzone.qnt: the depth, disabled, the batch, and the invariant that a drop or a leave clears the highlight). test/dropzone.browser.test.tsx is the DOM oracle (the picker, the DataTransfer details, the attributes), test/dropzone-spec.browser.test.tsx replays the spec's scenarios and the differential walk in Chromium, and the per-file decision (accept, maxSize, maxFiles) is a property test there. The same primitive replaces the bare file inputs of cms-admin's image field and kocharin's dashboard upload.
const upload = createDropZone({
accept: "image/*",
multiple: true,
maxSize: 5 * 1024 * 1024,
maxFiles: 10,
labels: { labelledby: "upload-heading", browse: "Choose images" },
formatMessage: ({ total, rejected }) => t("upload.batch", { total, rejected: rejected.length }),
onFiles: (files) => void add(files),
onReject: ({ file, reason }) => toast(`${file.name}: ${t(`upload.reason.${reason}`)}`),
});
<div {...upload.zoneProps}>
<p>Drop images here{upload.dragging() ? " (release to add)" : ""}</p>
<input {...upload.inputProps} />
<button {...upload.browseProps}>{upload.message() ?? "Choose images"}</button>
<p {...upload.statusProps}>{upload.message()}</p>
</div>;browseProps goes on a real <button type="button"> that clicks the hidden input, so the picker is the keyboard path (Enter and Space are the platform's) and a pointer user can click as well as drag. The browse button's text is the host's; labels.browse is its accessible name when that text is an icon.accept is the HTML grammar (.png, image/png, image/*), maxSize is bytes, maxFiles caps what one batch takes. A refused file reaches onReject with reason: "type" | "size" | "count"; the accepted ones reach onFiles in one batch, and a batch with nothing accepted calls neither.message() is a default sentence, "2 files, 1 rejected: too large", for the status region; the words are the host's, the primitive only tracks the counts of the last batch. It is undefined before the first file. formatMessage gets those counts (total, accepted, rejected) and returns the sentence in the host's language, so no app translates a string it did not write.labels.labelledby names the zone by the host's own visible heading (aria-labelledby), which wins over labels.zone; use it whenever the zone already has a heading next to it.DataTransfer is a no-op: no callback, no rejection, and the previous announcement stays.dragleave counts. A child's dragleave bubbles to the zone, so the state is a depth counter: dragging() clears only when the drag leaves the zone itself, or on a drop. dragging() is the styling hook — the primitive writes no data-*.disabled marks the zone aria-disabled, disables the input natively and the browse button, and drops every drag before it becomes a batch. Options are read when an attribute is read, so a host may flip it on a mounted zone.createPagination is a navigation landmark over a page list. No APG pattern exists; the requirements are TetraLogical's (accessible-components-library v1.0.0), and test/pagination.browser.test.tsx is the oracle.
const pages = createPagination({ page: 3, pageCount: 12, hrefFor: (page) => `/issues?page=${page}` });
<nav {...pages.navProps}>
<ul {...pages.listProps}>{/* items() with gaps, linkProps(page) */}</ul>
</nav>
<p {...pages.statusProps}>{pages.status()}</p>;aria-current="page" on the item and its link; the current page is not a link target.aria-disabled at the boundary instead of disappearing: a control that vanishes moves every other control under the pointer.siblings (default 1) either side of the current page and boundaries (default 1) at each end.role="status" line ("Page 3 of 12"), not in every link. Pass labels.status to translate it.hrefFor is what makes it work without JS: with it every page is a real link; without it they are buttons and the host owns navigation.createTable is sortable column headers and row selection on a native <table>: a <caption>, <thead>, <tbody>, <th scope="col"> and <td> carry the semantics, so the primitive adds no role and no aria-rowindex, only what the elements cannot say themselves (aria-sort on the sorted column, aria-selected on a row, the mixed select-all state, and the totals a windowed table hides). It is a grid with a header row but without the grid's navigation: the cells keep their own focus, and createGrid stays the widget for roving cell focus. There is no spec of its own — it composes the two state models the package already has, grid-sort.qnt and grid-selection.qnt — so test/table.browser.test.tsx is its oracle.
const table = createTable({
columns: [
{ key: "title", abbr: "Title" },
{ key: "status", sortable: false },
{ key: "count", numeric: true },
],
rows, // the host's ids, in the host's order, or `() => rows()` for a list that arrives later
selection: "multiple",
defaultSort: { key: "title", direction: "ascending" },
labels: { table: "Open issues", selectRow: (id) => `Select ${nameOf(id)}` },
onSortChange: (sort) => setSort(sort), // the host re-sorts its data and passes `rows` again
});
<table {...table.tableProps}>
<caption {...table.captionProps}>Open issues</caption>
<thead>
<tr>
{table.selectAllProps && (
<th>
<span {...table.selectAllProps} />
</th>
)}
{columns.map((column) => {
const sortButton = table.headerButtonProps(column.key); // undefined when not sortable
return (
<th {...table.headerCellProps(column.key)}>
{sortButton ? <button {...sortButton}>{column.key}</button> : column.key}
</th>
);
})}
</tr>
</thead>
<tbody>
{rows.map((id) => (
<tr {...table.rowProps(id)}>
{table.selectAllProps && (
<td>
<span {...table.rowCheckboxProps(id)} />
</td>
)}
{columns.map((column) => (
<td {...table.cellProps(id, column.key)}>{cellOf(id, column.key)}</td>
))}
</tr>
))}
</tbody>
</table>;sort()) and announces it; it never reorders anything. The host maps the descriptor onto its own array and renders rows again.aria-sort is on the sorted column only. A sortable header that is not sorted carries nothing (ARIA's default is "not sorted"), and a sortable: false column is fully inert: no aria-sort, and headerButtonProps is undefined, so the host renders no button and it is not a tab stop.ascending -> descending -> unsorted), so a table can be put back in its own order; sortCycle: "toggle" gives ascending <-> descending and never returns to unsorted, which is what the APG grid example does. A new column always starts ascending, and only one column is ever sorted."none" (the default), "single" or "multiple", over ids: selected() is the list, rowProps(id) carries aria-selected and a click that selects, and toggleRow / toggleAll are the programmatic path. The row's checkbox stops its own click from reaching the row, so the two controls never toggle the same row twice."multiple" (selectAllProps and rowCheckboxProps are undefined otherwise: one control over one selection is meaningless). It is a role="checkbox", not a native input: the mixed state of a native checkbox is a DOM property (indeterminate), and what a screen reader must hear is aria-checked="mixed". It toggles the rows the table renders — a windowed table therefore toggles its window and keeps the rest of the selection.rowCount / columnCount: then aria-rowcount and aria-colcount are carried, and every cell gets its aria-colindex. A table that renders all of them carries neither (it would only repeat what the markup says).numeric is a layout hint for the host's skin (right alignment, tabular figures): HTML has no attribute for it, so the primitive carries nothing.createModifiers is MuTable's mechanic (Sun et al., UIST '26) as a rail: a transformation is data, not a command. Each one stays on the stack as a unit over the columns it spans — Color, Size, Axis, whatever the host declares — so the current view can be explained, revisited and extended instead of being a one-way command whose result is all that remains. One encoding has one owner (the topmost unit that covers the column and declares it), which is what makes the order mean something: Group then Count is not Count then Group. A unit that is joined (parts.length > 1) is the reusable sequence, and retargeting it moves every step of it.
const modifiers = createModifiers({
targets: [
{ key: "audience", label: "Audience" },
{ key: "critics", label: "Critics" },
],
actions: [
{ kind: "color", label: "Color", encodings: ["color"] },
{ kind: "axis", label: "Axis", encodings: ["y", "order"] },
],
defaultModifiers: [
{ id: "m1", targets: ["audience"], parts: [{ kind: "color", slots: [0] }] },
],
onActivate: (id) => setMenu(id), // the host's menu: span, lock, reorder, join, split, remove
});
<div {...modifiers.toolbarProps}>
<For each={modifiers.modifiers()}>
{(unit) => <button {...modifiers.itemProps(unit.id)}>{shortLabel(unit)}</button>}
</For>
</div>
<p {...modifiers.status.statusProps}>{modifiers.status.message()}</p>;Alt+ArrowUp/Down (dragging is the pointer's version of the same request), and Delete removes. The rail is a toolbar with one tab stop: arrows move, Enter/Space/Shift+F10 activates a unit, and the host decides what that opens — a menu (aria-haspopup="menu") or a panel of checkboxes and radios (aria-expanded + aria-controls, which is a disclosure and must not claim to be a menu).aria-label is Color, applied to Audience, Critics, locked to Audience: the span and the lock are the state a reader needs before acting, and an option's visible label is only the action's name.add, move, lock, joinWithAbove and the rest are requests (the createControllable split, as in createTable): a controlled host that ignores one gets no message, because nothing changed. The status region is the one from createStatus and says the delta — "Axis moved to position 2 of 4", "2 modifiers joined".locked, by position) and names it; what "the others inherit" means is the host's computation, the same split createTable makes with a sort. Adding a column to a unit is the brush, and it applies every step of the unit to it.encoded(key) and owner(key, encoding) say who owns what, and the host paints beside the value. mark — the "dense" cell — is a smaller rendering of the number, never an aria-hidden one: a table that turned its values into bars for a sighted reader must not turn them into nothing for the next one.test/modifiers.test.ts is the oracle (ownership by order, join/reuse/split, the lock, and the announcements).createTimeline has two modes over one axis. Without rows it renders the package's demo tree of five fixed spans (collapsing, a zoom window, the differential walk against specs/apg/timeline.qnt); with rows it takes real span data and lays it out as a trace waterfall.
const timeline = createTimeline({
rows: spans, // { id, label, start, end, depth?, status? }, in the host's display order
axis: { unit: "ms" },
selected: selected(), // controlled; omit it and the primitive keeps the value
onSelect: (id) => setSelected(id),
});
<ul {...timeline.listProps}>
{spans.map((span) => (
<li {...timeline.rowProps(span.id)}>
<span {...timeline.labelProps(span.id)}>{span.label}</span>
<div class="track">
<div {...timeline.barProps(span.id)} />
</div>
</li>
))}
</ul>
<div {...{ role: timeline.rulerProps.role }}>
{timeline.rulerProps.ticks.map((tick) => (
<span style={{ left: `${tick.left}%` }}>{tick.label}</span>
))}
</div>;role="list" / role="listitem" (see listProps / rowProps) with aria-level = depth + 1, so the nesting a flat DOM cannot show is still announced; the selected row is aria-current="true", which every element may carry — aria-selected is not allowed on a listitem and a waterfall is not a selection control. The demo tree keeps role="tree" / treeitem, because it does collapse.extent() is the smallest start and the largest end, so a nested span is positioned and sized as a percentage of the whole trace, not of its parent. barProps(id).style is left / width in percent of that extent. A zero-length span (a marker, start === end) still paints: every bar has a 0.5% floor (2 px on a 400 px track), the floor the o11y dashboard hand-rolled before this mode existed.--depth on barProps and labelProps, so a narrow track keeps its indentation: padding-inline-start: calc(var(--depth) * 0.75rem). Nesting the label's DOM would steal width from the bar.rulerProps.ticks is the extent stepped by 1, 2 or 5 times a power of ten (about five ticks), each { value, left, label } with the label in the axis.unit (default ms). The ruler itself is decorative (role="presentation", aria-hidden="true"); render the ticks as children.selected + onSelect make it controlled (selected is a request the host may ignore); select(id) is the programmatic request.status is carried as data-status on the row for the host's colour, and label never leaves the host's data: the primitive does not invent the row's text.createTabs is the APG tablist: roving tabindex, wrapping arrows, Home/End, automatic or manual activation, disabled tabs, and a selection that is a request (value + onValueChange) or uncontrolled (defaultSelected). The plain widget is checked against specs/apg/tabs.qnt by the scenario bridge and the differential walk in test/tabs.browser.test.tsx; its roles, names, focus order and direction are held by test/tabs-requirements.browser.test.tsx.
dir (default ltr) swaps ArrowLeft / ArrowRight on a horizontal tablist, the way radio.ts does; a vertical tablist keeps Up / Down. tabs.qnt models ltr only, so the ported direction scenarios stay skipped in the differential walk: the primitive's arrow swap is proven by the browser test, not by the model.
Its accessibility requirements — one row per requirement, each naming the Quint invariant, browser test or manual AT row that holds it, and the gaps still open — are docs/requirements/tabs.md, written on the model in docs/requirements/README.md: a behaviour goes to the spec and its walk, a DOM attribute or a layout value to a browser test, and what a screen reader says to the assistive-technology table.
The docs playground's file tabs add and close files and rename them, so createTabs also takes closable and renamable — both off by default, so the plain widget is unchanged. The primitive never takes the list: it asks (onClose, onRename), the host removes or renames. label(index) is the tab's name: it names the close and rename buttons and seeds the rename draft, and it is read lazily.
const tabs = createTabs({
get items() {
return files().length;
}, // the host's list; it shrinks after a close
get closable() {
return true;
},
get renamable() {
return true;
},
label: (index) => files()[index], // "Close index.ts", the rename draft
onClose: (index) => setFiles((all) => all.filter((_, at) => at !== index)),
onRename: (index, label) =>
setFiles((all) => all.map((name, at) => (at === index ? label : name))),
});
<div {...tabs.tablistProps}>
{files().map((name, index) => (
<div {...tabs.tabProps(index)} onDblClick={tabs.renameProps(index).onDblClick}>
{tabs.renameProps(index).editing() ? (
<input
{...tabs.renameProps(index).inputProps}
ref={(element) => queueMicrotask(() => element.focus())}
/>
) : (
name
)}
</div>
))}
{/* ... the close button of each tab, and the panels */}
</div>;closeProps(index) is the tab's close button: aria-label "Close inputProps instead of its label. Enter commits, Escape reverts, blur commits; a label that trims to nothing cancels. An <input> cannot live in a <button>, so the tab becomes a role="tab" element while it is editing. While editing the input owns the keys: the tablist's roving does not move, and an arrow key leaves the caret alone. begin(index) is the programmatic start (a tab the host has just added: append it, then focusTab(index) and begin(index)).editing() is the tab being renamed, null when none. items is read from the option on every read, so the bounds, the roving tab stop and firstEnabled follow a host that shrinks its list.tabId(index) and panelId(index) replace the generated ${id}-tab-<index> / ${id}-tabpanel-<index>, and aria-controls / aria-labelledby follow them: an o11y console whose panels are #traces, #logs, #metrics no longer has to re-implement the two attributes.deletable flavour (Delete, focus to the next tab, the last refused) but no rename and no callbacks, so test/tabs-close.browser.test.tsx is the oracle for all of it.createConfirm is a promise-based confirmation over createDialogModal({ role: "alertdialog" }). Like the field it is not checked against a spec (the dialog is; test/confirm.browser.test.tsx covers the promise around it, in Chromium).
const confirm = createConfirm();
const remove = async () => {
if (await confirm.confirm({ title: "Delete post?", description: "This cannot be undone.", confirmLabel: "Delete", destructive: true })) {
await deletePost();
}
};
<button {...confirm.triggerProps} onClick={remove}>Delete</button>
<div {...confirm.backdropProps} />
<div {...confirm.dialogProps}>
<h2 {...confirm.titleProps}>{confirm.request()?.title}</h2>
<p {...confirm.descriptionProps}>{confirm.request()?.description}</p>
<button {...confirm.cancelProps}>{confirm.request()?.cancelLabel}</button>
<button {...confirm.confirmProps}>{confirm.request()?.confirmLabel}</button>
</div>;confirm(request) resolves true on the confirm button, false on cancel, Escape or a click on the backdrop. onOpenChange fires when it opens and when it settles.confirm() while one is pending rejects with ConfirmPendingError and leaves the first alone; it is not queued (a double click on "Delete" would ask twice, and a queued question can outlive the screen that asked it). A pending request is answered false when the owner is disposed.confirm() was called, before the promise resolves, so the caller may move it on.overflow: hidden is set on document.documentElement and the inline value it had is restored on close, on dispose and on every way the request settles; add scrollbar-gutter: stable to the page if the vanished scrollbar must not shift the layout (the lock does not pad for it). Escape is read from the document, in the capture phase, so it answers false wherever the focus is, and it stops there: the elements around the dialog (a dialog the confirm sits in) do not see it. The backdrop click is backdropProps, as before; keep the backdrop and the dialog siblings, or a click inside the dialog reaches the backdrop. Making the rest of the page inert or aria-hidden is still the host's.createConfirm calls may be open together (a "discard changes?" over a "delete?" that opened it): the one opened last gets Escape and Tab, the one under it waits, and the scroll lock is counted, so the first takes it and the last to close restores it. One createConfirm is still one request at a time. A createDialogModal that is open under a confirm knows nothing of this stack."Confirm" and "Cancel", stay English. An app that translates passes confirmLabel and cancelLabel (and the title) with each request, confirm({ title: t("unsaved"), confirmLabel: t("discard"), cancelLabel: t("keep") }); a label left out, or undefined, falls back to the English default. Nothing in the options needed to change for this: ConfirmRequest already carried both labels.aria-labelledby is the title and aria-describedby always the description (an alertdialog needs one), so render descriptionProps always: it is hidden when the request has no description. triggerProps are dialog-modal's trigger attributes without the handlers; the click that calls confirm() is the host's. request() keeps the last request after it settles, so a closing animation does not flash empty.Two live regions for the two sizes of feedback: createStatus is one role=status message whose text the host replaces ("Link copied", "Saved"); createToast is a queue of toasts, each with its own live region, a timeout, a ceiling and a countdown that pauses. Neither touches the DOM: like every primitive here they return state and attribute objects. There is no APG pattern for either (APG's Alert, createAlert, is imperative and assertive), so there is no Quint spec and test/toast.browser.test.tsx is the oracle. The behaviour is copied from Base UI's Toast and React Aria's Toast (a landmark, F6 into it, at least 5 s, timers paused on hover or focus, the announced text handed in rather than read from the DOM).
const toast = createToast();
const status = createStatus();
const copy = async () => {
await navigator.clipboard.writeText(url);
status.show("Link copied");
};
const upload = async () => {
try {
await send(file);
toast.show({ title: "Uploaded", description: file.name, tone: "success" });
} catch {
toast.show({
title: "Upload failed",
description: "Try again from the file row",
tone: "error",
});
}
};
<p {...status.statusProps}>{status.message()}</p>;
<div {...toast.regionProps} tabindex={-1}>
<For each={toast.toasts()}>
{(item) => (
<div {...toast.toastProps(item.id)}>
<p>{item.title}</p>
<p>{item.description}</p>
<button type="button" onClick={() => toast.dismiss(item.id)}>
Dismiss
</button>
</div>
)}
</For>
</div>;show(text) writes the one region and clear() empties it; a second message before the first is read replaces it. When the text is already a signal, pass from: () => message() instead and drop show/clear: the primitive reads the signal, so nothing has to mirror it with an effect. createAlert takes the same option (from: () => error()), and an accessor that returns undefined unmounts the alert. A status is never for errors: an error is createAlert (role=alert, assertive), and a titled message with a timeout is a toast.toastProps(id).role is "alert" for tone: "error" and "status" otherwise, so an error interrupts and the rest wait. The container is role="region" with aria-label ("Notifications" unless labels.region), and each toast is aria-atomic, so its title and description are announced as one — the toast's own text is the announcement, a close button's label included, so keep a toast to its title and description. The role sits on the toast rather than on one container per tone: the container is the region landmark, so it cannot also be the live region, and a role per toast needs no second region from the host.timeout defaults to 5000 ms, the five seconds Base UI and React Aria call the minimum for reading a message; shorter values are for tests. One timer per toast, cleared by dismiss/dismissAll and all of them on dispose.onDismissRequest handlers, a handler returns true when it owns that row, and the renderer calls dismiss(id) once the row has finished leaving, so the departure can be animated. With no handler, none that claims the id, and always for dismiss, dismissAll and the ceiling, the toast leaves at once; requestDismiss(id) is the same ask for a host's own imperative dismissal.pauseOnHover: false leaves focus as the only pause. The countdown reads an injected clock (systemClock by default): a test passes createFakeClock(), advances it, and proves that a paused countdown resumed from where it stopped rather than restarted — no wall clock and no sleep in the test.max (default 3) keeps the newest: a show past it drops the oldest. onDismiss(id) fires for every toast that leaves, whichever way — a timeout, a dismiss, dismissAll or the ceiling.tabindex="-1" and focus it from the host's F6 handler, remembering the element to restore. The primitive binds no keys: global hotkeys are a separate piece (bean cssints-h0d5).createPopover is the non-modal overlay: an anchored surface a trigger opens, dismissed by a click on the trigger, an outside pointerdown or Escape, with focus moving into it and back to the trigger. There is no APG pattern for a popover (APG has Dialog, which is modal), so there is no Quint spec and test/popover.browser.test.tsx is the oracle. It is copied from Base UI's Popover (the trigger click toggle, Enter / Space / ArrowDown, light dismiss on an outside pointerdown that does not steal focus) and React Aria's usePopover (focus in on open, back on close, role="dialog" without aria-modal, a placement that flips at the viewport edge).
const popover = createPopover({ placement: "bottom-start" });
let trigger!: HTMLButtonElement;
let content!: HTMLDivElement;
onMount(() => {
const teardown = popover.attach(trigger, content);
onCleanup(teardown);
});
<button {...popover.triggerProps} ref={(element) => (trigger = element)}>Filters</button>
<div {...popover.contentProps} style={popover.contentStyle()} ref={(element) => (content = element)}>
…
</div>;attach(trigger, content) is the whole DOM contract and returns its teardown: it measures and places on open (and on resize, scroll and a ResizeObserver), focuses the first focusable element in the content (else the content itself, which is tabindex="-1"), returns focus to the trigger on a close it caused, and closes on a pointerdown outside both elements. Call it from a ref; it creates an effect.position(triggerRect, contentRect, viewport) is pure: it returns { top, left, placement } for the requested placement, flipped to the other side when the room is not there, and shifted (not flipped) into the viewport horizontally. The rects and the viewport must share a space; attach measures in client space and writes page space for position: absolute.inert, no scroll lock, no Tab cycle, no aria-modal. That is createDialogModal, and modal is typed false for that reason.createTooltipGroup), submenus and item navigation (the menu), a scroll lock and inert (the modal dialog), and a vertical shift when neither side fits (the caller sees the requested placement).createDrawer is the drawer / sheet shell: an edge-anchored panel over the Dialog (Modal) semantics, with the same focus, Escape, scroll-lock and backdrop behaviour as createConfirm. No APG pattern exists for a drawer or a bottom sheet, and docs/bottom-sheet.md settled that the library composes rather than adding a sheet primitive: the semantics are Dialog (Modal), the position, the slide and the snap points are the host's native CSS, and this is the panel both were missing. test/drawer.browser.test.tsx is the oracle.
const drawer = createDrawer({ side: "right", labelledby: "nav-title" });
<button {...drawer.triggerProps}>Menu</button>;
<div {...drawer.backdropProps} />;
<div {...drawer.contentProps}>
<h2 id="nav-title">Site</h2>
<nav>{/* links */}</nav>
</div>;side is presentation only, "right" (the default), "left" or "bottom": a sheet is { side: "bottom" }, a side rail is { side: "left" }, and it is one API either way. The primitive lays out nothing; the host's CSS anchors the panel, and handleProps is the grab handle of a sheet.modal is the breakpoint switch. It is read on every attribute read, so a host may flip it while the drawer is open (crossing the breakpoint) and aria-modal, the backdrop and the lock follow. breakpoint is a px number the primitive does not read: it has no viewport, so the host watches matchMedia and passes side and modal. A sheet below a breakpoint is modal; a side rail above it may not be.aria-modal="true", a backdrop, focus into the panel's first focusable on open (else the panel, which is tabindex="-1") and back to the trigger on close, Tab and Shift+Tab cycling inside, overflow: hidden on document.documentElement counted (as in createConfirm, and shared with it: a confirm over a drawer nests), and Escape read from the document in the capture phase, so it closes wherever the focus is. Non-modal: no aria-modal, no backdrop, no lock and no Tab trap, so the page keeps its scroll and its clicks; an outside pointerdown still dismisses it when dismissable, and Escape still closes it.dismissable: false keeps the backdrop and an outside pointerdown from closing the drawer; Escape still closes it, because there is no way out otherwise.scroll-snap-type: y mandatory, snap markers, scrollsnapchange; see docs/bottom-sheet.md). Re-implementing a native snap in pointer events would be the gesture duplication that research forbids, and the handle would drag on top of the snap that already moved the panel. So handleProps is decoration (aria-hidden, no pointer handlers) and the ways out are the backdrop, Escape, a close control the host puts in the panel, and the trigger. Swipe-to-dismiss, if it is ever wanted, is a separate decision with its own oracle.attach. The panel is edge-anchored: nothing is measured and no placement is computed, so focus and the Tab cycle find the panel through contentProps.id and the host only spreads attributes onto its own elements. Give the panel a name: pass labelledby, or set aria-labelledby / aria-label after the spread.createDiagramFocus is the readable twin of a canvas: the same nodes and edges, positioned by the host, as one roving tab stop plus a keyboard cursor over the outgoing edges, with a polite live region saying where the user is. The APG has no pattern for a diagram (a graph is not one of the 44 patterns), so there is no Quint spec and no ported scenarios: test/diagram.browser.test.tsx is its oracle. What it borrows is the grid's roving tabindex (exactly one node in the tab order, so Tab leaves the composite), WAI-ARIA's aria-roledescription="node" on each role="button", and the role="status" / aria-live="polite" region of createStatus for the announcement.
const nodes = [
{ id: "payment", label: "Payment", x: 0, y: 0, width: 160, height: 80 },
{ id: "pending", label: "Pending", x: 260, y: 0, width: 160, height: 80 },
{ id: "failed", label: "Failed", x: 260, y: 140, width: 160, height: 80 },
];
const edges = [
{ id: "submit", from: "payment", to: "pending", label: "submit" },
{ id: "fail", from: "payment", to: "failed" },
];
const diagram = createDiagramFocus({
nodes,
edges,
onActivate: (id) => select(id),
onEdgeActivate: (id) => fire(id),
// the graph is the host's: `c` and Enter, or a drag, only say which pair was asked for
onConnect: (from, to) => setEdges((all) => [...all, { id: nextId(), from, to }]),
});
<div role="group" aria-label="Checkout state chart">
<div style={{ position: "relative" }}>
<For each={nodes}>
{(node) => (
<button
{...diagram.nodeProps(node.id)}
style={{ position: "absolute", left: node.x, top: node.y }}
>
{node.label}
</button>
)}
</For>
<For each={edges}>
{(edge) => (
<button {...diagram.edgeProps(edge.id)} style={{ position: "absolute" }}>
{edge.label}
</button>
)}
</For>
</div>
<p {...diagram.statusProps}>{diagram.status()}</p>
</div>;onActivate), and e.c starts a link from the active node, the arrows pick the node it should join, Enter fires onConnect(from, to) and Escape forgets it; canConnect(from, to) refuses a pair and leaves the link pending, so another target can be chosen. The tab stop is the target, so the live region says the pair ("Link Payment to Pending. Enter to connect, Escape to cancel") and the same state is what a host's pointer drag reports to: diagram.startConnect(id) on the press, diagram.connectTo(id) on the release (or cancelConnect() on nothing), diagram.connectFrom() for the line it draws. The big node libraries (React Flow, Svelte Flow, Vue Flow) announce and move nodes by keyboard but make every connection with a pointer; this is the one part of that model they leave out.e opens the outgoing edges. The cursor starts on the first edge of edgesOf(active) (in option order, endpoints present) and the live region reads "Edge Payment → Pending. Enter to activate". Arrows move the cursor and wrap, Enter (or Space) fires onEdgeActivate, Escape — or any other navigation key — leaves the cursor. edgeCursor() is -1 while off and setEdgeCursor(index) is the programmatic version.status() says "Payment. 2 edges: to Pending, to Failed" or the edge sentence; it is derived, so it changes with every move (that is what makes a screen reader read it). Render it once and always: statusProps is { role: "status", "aria-live": "polite" }. When the diagram is empty, status() is empty and nothing is tabbable.nodeProps sets tabindex="0" on it and -1 on the rest, and onFocus moves the tab stop to whatever node took focus — so a host that focuses the node it selects keeps the two in step.nodeProps also carries an element id (<base>-node-<node id>, the base from options.id or generated), so an arrow, Home / End or focus(id) focuses the node it landed on: the host needs no effect, and the tab stop and document.activeElement cannot disagree. A host that renders a node outside the document (a portal on another document) moves focus itself.nodes is a no-op in nodeProps / focus; an edge whose endpoint is missing is ignored everywhere. A node that arrives later is fine: the lists take getters (() => nodes()), read at attribute-read time, and the tab stop keeps its node while it exists, else falls back to the first.labels names the diagram in every announcement ("State chart. Payment. 2 edges: …") and the edge noun (edges: "transitions"); absent, both are left out and English.createHotkeys is a platform utility, not a widget: one registry for the chords every app hand-rolls (the docs app's / and Cmd/Ctrl+K, the CMS's Cmd/Ctrl+S). No APG pattern exists for a keyboard registry, so there is no role, no element, no styling and no Quint spec; test/hotkeys.browser.test.tsx is the oracle.
const hotkeys = createHotkeys();
onSettled(() => {
hotkeys.bind({
keys: "mod+k",
onTrigger: () => searchEl.focus(),
});
hotkeys.bind({
keys: "/",
when: () => !dialog().open,
onTrigger: () => searchEl.focus(),
});
hotkeys.bind({
keys: "mod+s",
scope: editorEl,
onTrigger: () => save(),
});
return () => hotkeys.dispose();
});bind adds a chord to one keydown listener on the document in the capture phase (a scope only filters the event's target, it does not add a listener), and the last binding to go is the one that removes it; dispose unbinds everything and a later bind is a no-op. The unbind bind returns is idempotent.mod is Cmd on macOS and Ctrl elsewhere (isApple injects the answer, so a test does not read the runner's OS); ctrl, alt, shift and meta are as written. A chord that does not declare Shift does not fire with Shift held. A shifted character implies Shift: "?" fires from Shift+/ even without "shift+?", and "/" does not fire from it.input, a textarea or a contenteditable (an inherited one included) unless it sets allowInEditable, which is what Escape wants: it closes a dialog wherever the focus is."/" shadows the page's and unbinding it brings the page's back; a when that is false makes the next match fire instead, so the gate can close without unbinding.preventDefault is on for a binding that fires (Cmd/Ctrl+S and Cmd/Ctrl+K would otherwise reach the browser); pass false to let the platform act too.Collisions with the browser's own chords: preventDefault reaches the page's default action, not the browser's. Cmd/Ctrl+S (Save Page), Cmd/Ctrl+K (the browser's search, in Chrome and Firefox), Cmd/Ctrl+P and / (Firefox's quick find) can be cancelled by a page, and a host that binds one is choosing to take it from the browser; Cmd/Ctrl+T, Cmd/Ctrl+W, Cmd/Ctrl+N, Cmd/Ctrl+L and F11 are reserved and cannot be intercepted, so a chord built on them never fires. keys takes any of them the same and says nothing.
createScrollProgress is the scroll position of a container as a fraction, for a reading-progress bar or a value a canvas renders by hand. No APG pattern exists for a progress bar driven by scrolling, so there is no Quint spec and no ported scenarios: the contract is WAI-ARIA (role="progressbar", aria-valuemin/max/now) and HTML, and test/scrollprogress.browser.test.tsx is its oracle.
const reading = createScrollProgress({ root: () => pane });
onSettled(() => reading.attach()); // returns the teardown
<div class="track">
<div {...reading.barProps} style={`scale: ${reading.progress()} 1`} />
</div>;animation-timeline: scroll(), @cssints/reveal's progress() draws the same bar with no listener at all; this primitive is what keeps the bar's progressbar value right (an animation carries none) and what moves the fill everywhere else. One element can carry both: a running animation beats an inline style, so the two never draw at once.progress() is 0 at the top, 1 at the end, and 1 when there is nothing to scroll. A short page is fully read, so its bar is full; an indeterminate bar would say "unknown" about a page with no reading left.attach() adds one passive scroll listener on root() (the document by default; read once), one ResizeObserver on what is scrolled (a nested pane's content can grow without a viewport change), and syncs once, so a page opened mid-scroll starts correct.axis: "inline" reads the horizontal scroll of the container (scrollLeft, scrollWidth - clientWidth) instead of the block one.scrolled() and distance() are the pixels, for a bar that also prints them; barProps["aria-valuenow"] is the rounded percentage.onChange fires when the value changes, not on every scroll event of a still bar.createScrollspy is a table of contents whose current entry is the last heading to reach the top of the scrollport. No APG pattern exists for a scrollspy (the APG has no table-of-contents pattern), so there is no Quint spec and no ported scenarios: the contract is WAI-ARIA — aria-current="location" on the current link, exactly one link at a time, role="list" / role="listitem" for the list, and a named navigation landmark — plus HTML (#id targets). test/scrollspy.browser.test.tsx is its oracle.
const toc = createScrollspy({
entries, // { id, label } in document order: the ids are the headings'
offset: 96, // a sticky header's height
onChange: (id) => track(id),
});
onSettled(() => toc.attach()); // returns the teardown
<nav {...toc.navProps}>
<ul {...toc.listProps}>
<For each={entries}>
{(entry) => (
<li {...toc.itemProps(entry.id)}>
<a {...toc.linkProps(entry.id)}>{entry.label}</a>
</li>
)}
</For>
</ul>
</nav>;IntersectionObserver. "The last heading at or above the offset" is a total order over every heading, and an observer only reports what crossed its band: a band observer has to rebuild the order from its enter/leave state and misreports after a jump (an anchor click, a restored scroll position). The listener is passive, the measurements are reads only (no writes, so no layout thrash), and a docs page has a dozen headings — the same cost as the listener the page already keeps.attach() adds that one listener to root() (the document by default; read once, so attach again after swapping containers), calls it once to sync a page opened mid-scroll, and returns the teardown. Headings are looked up by id on every scroll, so they may render after attach; an id with no element is skipped.offset is px below the scrollport's top edge, not the viewport's, so an inner container plus a sticky header works: offset is the header's height inside that container.active() is undefined only when there are no entries.aria-current="location", on the link, never on the heading: the heading's own id is the target. Skin it with a[aria-current="location"].#id targets, the primitive never moves the scrollport, so scroll-behavior: smooth (and any prefers-reduced-motion override) belongs to the page's CSS; there is no scroll helper to reduce.navProps first and override it after: <nav {...toc.navProps} aria-label={t("onThisPage")}>.createVirtualizer renders a window of a long list instead of the list: the visible rows plus an overscan, with two spacer boxes standing in for the rows above and below, so the content height, the scroll's clamp and its thumb stay the whole list's. It ports the rules the native renderer already had (native/solid/src/virtual.ts): the arithmetic of a fixed row, the measured mode that declares everything until every height is in and then virtualises, the gap-compensated spacers (above = first·(item + gap) − gap), no spacer at an end, and OVERSCAN two. The DOM adds the scrollport (attach), the ResizeObserver that reads the heights (the native renderer reads a row's box from ui.bounds after layout), and the ARIA pair. There is no APG pattern for virtualisation and no Quint machine — the state is pixels — so test/virtual.browser.test.tsx is the oracle.
const list = createVirtualizer({
count: () => rows().length, // 10 000: the whole list, not the window
itemSize: 40, // fixed rows; omit it (or pass an estimate per index) to measure
gap: 4,
});
const range = createMemo(() => {
const at = list.window();
return Array.from({ length: at.last - at.first + 1 }, (_, step) => at.first + step);
});
<div class="port" {...list.scrollProps} ref={(element) => list.attach(element)}>
<div class="column">
<Show when={list.window().above > 0}>
<div {...list.spacerProps("start")} />
</Show>
<For each={range()}>
{(index) => (
<div role="listitem" {...list.itemProps(index)}>
{rows()[index]?.title}
</div>
)}
</For>
<Show when={list.window().below > 0}>
<div {...list.spacerProps("end")} />
</Show>
</div>
</div>;.port {
height: 600px;
overflow: auto;
}
.column {
display: flex;
flex-direction: column;
row-gap: 4px; /* the option's gap */
}first·(itemSize + gap). At an end there is no spacer, so render one only while its height is positive (window().above > 0 / window().below > 0, as the two Shows do): a zero-height box would still add the gap.attach creates no computation, so it is safe from a ref (Solid 2 runs refs in the effect phase, where createPopover's old attach threw PRIMITIVE_IN_EFFECT_CALLBACK). It records the scrollport, adds a passive scroll listener and the observers, and returns the teardown; the measured mode needs it. scrollProps.onScroll is the same sync as a prop for hosts that wire scrolling themselves.itemSize is arithmetic. A function, or no itemSize, measures the declared rows: while any height is unknown the whole column is declared (one frame pays the layout), and every frame after it has exact heights, so the content's end and the thumb do not move as rows are first seen. An unmeasured row is the per-row estimate, else estimate, else the mean of the measured, else 190.count shrinking drops only the heights past it. Growing again leaves those indexes unknown, so the pass runs for the new rows.aria-setsize is the whole count and aria-posinset is index + 1 on every declared row, so a screen reader says "row 4,321 of 10,000" while 20 exist. A table host adds aria-rowindex itself: it counts the header row, which the primitive cannot know (and createTable carries aria-rowcount).scrollToIndex(index) when your keys move focus to a row the window may not declare; it scrolls the least amount that shows the row, and does nothing when the row is already fully visible. The list then declares the row; focus it once it is there (an effect on window() whose callback runs when the target index is inside it), never before. In the measured mode the first offset is an estimate: the primitive keeps the target and lands again as the heights arrive, and a hand scroll cancels the pending jump.bun run test -- virtual # the 10,000-row list, the measured pass, the count changeThe first composition on the primitives — no new widget, no new spec: createCommandPalette is createDialogModal (a modal dialog) + createTextInput (the field) + createStatus (the count), wired into the shape docs/research/compositions-2026-10.md settles.
const palette = createCommandPalette({
commands, // ReadonlyArray<{ id, label, group?, keywords?, run(): void | Promise<void> }>
hotkey: "mod+k", // what attach() binds; this is the default
labels: { title: t("palette"), placeholder: t("search"), empty: t("empty") },
});
onSettled(() => palette.attach()); // one document hotkey; returns the teardown
const groups = () => [...new Set(palette.results().map((result) => result.group ?? ""))];
<button
aria-haspopup="dialog"
aria-expanded={palette.open()}
onClick={() => palette.openPalette()}
>
Commands
</button>
<div {...palette.backdropProps} />
<div {...palette.dialogProps}>
<h2 {...palette.titleProps}>{palette.labels.title}</h2>
<input {...palette.inputProps} />
<div {...palette.listProps}>
<For each={groups()}>
{(group) => (
<section>
<h3>{group}</h3>
<For each={palette.results().filter((result) => result.group === group)}>
{(result) => <div {...palette.optionProps(result.id)}>{result.label}</div>}
</For>
</section>
)}
</For>
</div>
<p {...palette.emptyProps}>{palette.labels.empty}</p>
<div {...palette.statusProps}>{palette.status()}</div>
</div>;input[type=text][role=searchbox] with no aria-autocomplete and no aria-haspopup, the container is role=dialog (a trigger says aria-haspopup="dialog"), and the list is a role=listbox named by the title. Nothing is changed by typing.aria-activedescendant names the highlighted option; ↓ past the last and ↑ before the first put the highlight back on the field (the attribute is absent), and ↓/↑ from there re-enter the list at the first/last row. Home/End move the caret while the field has text and are list keys (first/last) only while it is empty. Enter runs the highlighted command; Escape closes through the dialog; Tab is not intercepted, so the dialog's own focus policy applies.label and keywords. No fuzzy scoring: a palette holds tens of commands, and ranking (recents, scopes, weighted keywords) is a policy the host owns — a typo hiding a command is worse than an extra row. results() keeps host order.result.group (or undefined) is what the host groups by; it renders the headings and the CSS. emptyProps.hidden is false when nothing matches, and labels.empty is the text to show. The count lands in one polite region (statusProps, status()), written once per query change — moving the highlight does not re-announce it.run may return a promise, and moving the highlight to the next command is the host's call); closing on anything but Escape or a command; every visible string through labels; and the dialog's title element, which carries titleProps (aria-labelledby points at it).The second composition, again no new widget and no new spec: createFilterableMenu is createDialogModal (the popup, announced as a dialog) + createTextInput (the field) + createStatus (the count), with one filtered role=menu beside the field. It follows Base UI's Building a filterable menu that works for everyone, which docs/research/compositions-2026-10.md settles for us.
const menu = createFilterableMenu({
items: actions, // ReadonlyArray<{ id, label, group?, submenu?, run }> or a getter
labels: { placeholder: t("filter"), empty: t("noneFound"), clear: t("clear") },
});
const groups = () => [...new Set(menu.results().map((row) => row.group ?? ""))];
<button {...menu.triggerProps}>Actions</button>
<Show when={menu.open()}>
<div {...menu.backdropProps} />
<div {...menu.dialogProps}>
<h2 {...menu.titleProps}>{t("actions")}</h2>
<input {...menu.inputProps} />
<button {...menu.clearProps}>×</button>
<div {...menu.menuProps}>
<For each={groups()}>
{(group) => (
<div {...menu.groupProps(group)}>
<h3 {...menu.groupLabelProps(group)}>{group}</h3>
<For each={menu.results().filter((row) => (row.group ?? "") === group)}>
{(row) => (
<div
{...(row.hasSubmenu
? menu.submenuTriggerProps(row.id)
: menu.itemProps(row.id))}
>
{row.label}
</div>
)}
</For>
</div>
)}
</For>
</div>
<p {...menu.emptyProps}>{menu.emptyProps.text}</p>
<div {...menu.statusProps}>{menu.status()}</div>
</div>
</Show>;aria-activedescendant names the highlighted row; ↓ past the last and ↑ before the first put the highlight back on the field, which carries data-highlighted so the step is visible. ↓/↑ from the field re-enter at the first/last row. Home/End are menu keys (first/last row) only while the query is empty and a row is highlighted; with text they move the caret. Enter runs the highlighted row, or enters its submenu.showModal()) keeps its trap and moves first; this composition adds no second one. Escape goes back one submenu level and closes the dialog at the top level; Backspace on an empty submenu field goes back too.compositionend applies it. event.isComposing is honoured on the keyboard as well.groupProps / groupLabelProps (aria-hidden, because the group is already named through aria-labelledby) are the grouping; emptyProps.hidden and emptyProps.text are the empty state ("No actions found"); the count lands in one polite region (statusProps, status()) once per query change, not on every arrow. clearProps has tabindex: -1: the Clear button is a pointer affordance, not a tab stop.run is the host's to report) and their closing, every visible string through labels, and the dialog's title element (titleProps).filter: true on createMenu, with the IME guard and the arrow loop to the field) is a later composition on the same research.The second composition — no new primitive and no new spec: createDatePicker is createPopover (a non-modal trigger and popup) around a createGrid month (6 rows of 7 days), with createStatus for the selected day. The research (docs/research/compositions-2026-10.md, "Date picker") settles the shape; test/date-picker.browser.test.tsx is the oracle.
const picker = createDatePicker({
value: iso, // controlled ISO YYYY-MM-DD; or defaultValue
onValueChange: (next) => save(next), // a request: a controlled host may ignore it
min: "2026-01-01", // inclusive, ISO
max: "2026-12-31",
today: "2026-10-15", // injectable; the local date by default, so a test never reads the clock
firstDayOfWeek: 1, // Monday; 0 = Sunday
labels: { trigger: "Choose date", month: (year, month) => formatMonth(year, month) },
});
onSettled(() => picker.attach(triggerEl, popoverEl)); // the popover wiring + focus; returns the teardown
<button {...picker.triggerProps}>{formatDate(picker.value())}</button>
<div {...picker.popoverProps}>
<button {...picker.previousProps}>‹</button>
<h2 {...picker.headerProps}>{picker.headerProps.text}</h2>
<button {...picker.nextProps}>›</button>
<div {...picker.gridProps}>
<div role="row">
<For each={[0, 1, 2, 3, 4, 5, 6]}>{(index) => <div {...picker.weekdayProps(index)} />}</For>
</div>
<For each={picker.monthDays()}>
{(week) => (
<div role="row">
<For each={week}>{(day) => <div {...picker.cellProps(day)}>{day.slice(8)}</div>}</For>
</div>
)}
</For>
</div>
</div>
<div {...picker.statusProps}>{picker.status()}</div>;createPopover, not createDialogModal: nothing behind it becomes inert, there is no scroll lock, and Tab leaves the popup. The keyboard contract says Tab leaves, so a focus trap would contradict it; a date picker is one field, not a surface that keeps the user until they answer. The popup is role="dialog" with aria-modal absent, the trigger says aria-haspopup="dialog", and focus moves to the roving day on open and back to the trigger on close.Date.UTC(year, month, day) / 86_400_000). Leap years and month lengths are one Date read (2024-02-29 and 2023-02-28 are tests); a day, a week and a year are integer additions. No locale arithmetic and no @internationalized/date: a host with real calendars (Hebrew, Islamic, Buddhist eras) brings its own library and passes its ISO strings here. The trade is that a YYYY-MM-DD is read as a UTC midnight, which is the honest model for a civil date with no time and no zone.monthDays() is six weeks of ISO dates around the shown month, so the first row can start in the previous month and the last row can end in the next one. Every cell is a real, focusable date (a blank cell cannot hold the roving focus), and a cursor that leaves the month pages the grid to the month it landed in: ← on the 1st is the last day of the previous month and the title follows.cellProps(iso) gives aria-selected to the chosen date, aria-current="date" to today, aria-disabled outside min/max (inclusive), tabindex=0 to the roving day only and the grid's focusgroupstart to that same day. The roving stop is the selected day, else today when it is in the shown month, else the first day the bounds allow. A disabled day cannot be selected and never carries the tab stop. gridProps is the grid's role / aria-* only: the picker owns its keyboard and its roving day, and attach() finds the current cell by id, not by [tabindex="0"].tabindex that changes under a stationary caret is no use to a screen reader.aria-selected is per cell, not the grid's rectangle. The grid primitive has a range selection for a data grid; a calendar has exactly one value, so the picker writes its own aria-selected on the day and leaves the grid's selection unused. That is the one browser test the research left open ("does the grid reuse cover the value cell vs today") — the answer is that the grid's chrome is reused and the marks are the calendar's.hidden), the trigger's visible text (value() formatted), and any close other than Escape, a selected day or a click outside. labels.month and labels.weekdays localise the title and the column heads (the latter in getUTCDay() order, Sunday first); labels.day names a day for the polite announcement.createField + createSpinbutton over the same day numbers, with the trigger showing the formatted value — not a new primitive, and not part of this change.cd packages/headless
bun run test # vp test run: vitest browser mode, real Chromium (playwright; needs the browser installed: bunx playwright install chromium)
bun run typecheck # effect-tsrs
bun run build # vp pack: dist/ (ESM and declarations; solid-js is a peer)The browser runs at 1280x1024 (vite.config.ts): Vitest 5 defaults to a 414x896 viewport, and the canvas tests drag across a 1024 px viewport and measure how far content-visibility: auto looks ahead. The menu, treeview and listbox differential walks are slow, and can time out on a loaded machine; run them alone (bun run test test/menu.browser.test.tsx) before calling a failure real.
The specs, bridges and scenarios the tests replay are @cssints/apg-specs (a workspace dev dependency, published as its own package).
Published with the Changesets fixed group (one version with the other packages, RELEASING.md). Its manifest follows the other packages (development condition on src, dist for consumers, publishConfig.directory).
Solid 2 reminders: setters apply on the microtask flush (the DOM driver waits a frame after each step); pass props objects/getters, never destructure options.
<dialog> plus CSS scroll snap, not a primitive.