Skip to content

No.92 · Controls

Theme Dial

A theme picker built as an instrument: five themes along the light of a day (Daylight, Paper, Dusk, Ink, Midnight) on a half-dial. Drag the sun and every colour token is mixed continuously in OKLab between neighbours; let go and it settles into the nearest detent.

The prompt

Copy this text

Automatic copying is unavailable. Copy the selected text using your device’s copy command.

The design brief behind this component — reuse it to regenerate, remix, or explain it.

Build a theme selector that feels like a designed instrument rather than a dropdown or a hue wheel. The themes lie on one meaningful axis, the light of a day: - Daylight: cool white, blue accent. - Paper: warm ivory, terracotta. - Dusk: plum-clay mid-tone, apricot. - Ink: deep blue-grey, periwinkle. - Midnight: near-black, moon gold. Each theme defines the same tokens: bg, surface, ink, muted, accent and line. The control is a 150° half-dial in SVG. The arc track is stroked with a gradient of each stop's own background, so the day reads as a sequence of materials. It has major ticks at the stops, three minor ticks between each pair, a needle from a hub, and a 'sun' thumb on the arc filled with the current accent. Dragging anywhere on the dial maps the pointer angle to a continuous position t (0–4), and every token is interpolated in OKLab between the two neighbouring stops. The whole instrument and a live preview (a small app card with a stat, a chart line, a list and buttons) recolour as you scrub, and so does the page behind them via onPreview. On release, t eases into the nearest stop over 280ms (cubic out) and onChange fires with the stop's id and tokens. The readout under the arc shows the stop name in a serif, its note, and the live text contrast ratio of ink against the background. The thumb is role=slider with aria-valuetext ('Dusk: Low light, clay and plum'). Arrows, Page keys and Home/End step between detents, the wheel steps too, and a row of named stop buttons (each with a swatch) gives direct access. Side by side from 44rem of container width, stacked below it. Implementation requirements: Use React and TypeScript. Keep the component self-contained, with uniquely scoped CSS and no animation libraries. Include required imports, styles and font setup in the result. Interaction: Drag the sun along the arc, click a stop, or focus the dial and use ← → / Home / End. Motion: Continuous OKLab interpolation while scrubbing; a 280ms ease-out settle into the detent. Accessibility: The slider has aria-valuenow, aria-valuetext naming the theme and aria-orientation. Named stop buttons use aria-pressed, the chosen theme is announced politely, and the contrast ratio is shown for every stop. Reduced motion makes the settle instant; scrubbing still interpolates, because it follows your hand. Responsive behavior: The SVG scales with its container, and the preview stacks under the dial on narrow screens. Dragging uses touch-action: none on the dial only. Touch: Drag the sun with a finger or tap a named stop. Preserve keyboard access, visible focus and reduced-motion behavior. Keep fictional demo data and simulated service calls in a separate usage example; expose callbacks for real actions and recover from rejected requests. Keep usage-example links inside the demo: use local buttons or prevent navigation. Demonstration links must not navigate to Vitrine routes or open other pages; preserve real URL support in the reusable component itself. Verify the result at narrow and wide viewport sizes, with keyboard input and reduced motion enabled.

Notes

Interaction
Drag the sun along the arc, click a stop, or focus the dial and use ← → / Home / End.
Motion
Continuous OKLab interpolation while scrubbing; a 280ms ease-out settle into the detent.
Accessibility
The slider has aria-valuenow, aria-valuetext naming the theme and aria-orientation. Named stop buttons use aria-pressed, the chosen theme is announced politely, and the contrast ratio is shown for every stop. Reduced motion makes the settle instant; scrubbing still interpolates, because it follows your hand.
Responsive
The SVG scales with its container, and the preview stacks under the dial on narrow screens. Dragging uses touch-action: none on the dial only.
On touch
Drag the sun with a finger or tap a named stop.