Skip to content

No.88 · Controls

Ruler Picker

A number picked the way a tape measure is read: drag or flick the ruler under a fixed needle — it coasts, then settles exactly on a tenth — while ticks swell as they pass and the big readout rolls its digits. Switch kg ⇄ lb and the value converts while the ruler re-scales itself.

The prompt

Copy this text

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

Written for the variant you picked above: Paper

Build a horizontal ruler number picker (weight in kg/lb) as a role="slider" (aria-valuenow, valuetext "72.4 kilograms"). Ruler: a canvas under a fixed accent needle (a dot on a bar, ringed in the card colour). Draw only the visible window: ticks every 0.1 unit at 96px per unit — 12px tall, 20px at halves, 30px at wholes with numbers — each scaled up to 1.55× and darkened by a Gaussian of its distance from the needle (σ 70px), so ticks swell as they pass it. The ends fade out (destination-out gradient). A soft green band with a bottom edge marks a healthy range (56.7–76.4 kg for 1.75m), also described in text under the ruler. Motion (one rAF loop that sleeps when settled): dragging moves the value by −dx/ppu with pointer capture and tracks velocity; on release it coasts with friction (e^(−3.2t)) then eases onto the nearest 0.1 (rate 14/s). Wheel or trackpad scrolls it (horizontal or vertical delta) without scrolling the page. Keys: arrows ±0.1 (Shift ×10), Page ±5, Home/End. Readout: 64px semibold tabular digits, each a clipped strip of 0–9 translated to its digit with a 420ms ease, so digits roll as the value changes; the unit beside it. Units: a kg/lb segmented radiogroup. Switching converts the value (×2.20462) and sets pixels-per-unit to the old unit's spacing expressed in the new unit, then eases it to 96 — so the ruler visibly re-scales. Range 30–200 kg / 66–440 lb. Themes: paper and night. Reduced motion: no coasting, rolling or re-scale animation. Selected variant — Paper (paper): Palette for this theme (Paper): --accent #e2531f; --band rgb(47 191 113 / 0.14); --band-edge rgb(47 191 113 / 0.65); --card #fbf8f1; --edge rgb(0 0 0 / 0.07); --ink #1d1a15; --muted rgb(29 26 21 / 0.5). Treat these as the root colour tokens, one value per role, and name them to suit your code. Select it with the theme option set to "paper". Keep every dimension, spacing value, state and motion from the brief unchanged, and keep text at 4.5:1 contrast or better on these surfaces. This selection takes precedence over references to other themes or options in the general brief. Implement this selected appearance; do not add a variant picker or alternative appearances unless requested. 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 or flick the ruler, scroll over it, or focus it and use the arrows (Shift for whole units), Page keys, Home and End. Switch kg/lb above. Motion: Coast with friction then settle on a tenth; digits roll in 420ms; unit switch re-scales the ruler over ~0.4s. Accessibility: A slider with a spoken value and unit; the unit switch is a radiogroup; the healthy range is stated in text. Responsive behavior: The ruler fills the card's width (max 460px) and redraws on resize. Touch: Drag or flick with a finger; vertical page scrolling still works over it (touch-action: pan-y). 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 or flick the ruler, scroll over it, or focus it and use the arrows (Shift for whole units), Page keys, Home and End. Switch kg/lb above.
Motion
Coast with friction then settle on a tenth; digits roll in 420ms; unit switch re-scales the ruler over ~0.4s.
Accessibility
A slider with a spoken value and unit; the unit switch is a radiogroup; the healthy range is stated in text.
Responsive
The ruler fills the card's width (max 460px) and redraws on resize.
On touch
Drag or flick with a finger; vertical page scrolling still works over it (touch-action: pan-y).