Skip to content

No.87 · Controls

Histogram Range

A price range slider that shows you the data you're filtering: bars of the distribution sit behind the track, light up inside your range, and the result count updates as you drag.

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 two-thumb range filter drawn over the data it filters. A 72px histogram (36 bins, heights normalised to the tallest) sits directly above the track; bars whose centre falls inside the selected range turn accent, the rest stay dim — so you can see where the items are before you move a thumb. A mono 'N results' count updates live (aria-live). The track has a rail, an accent fill between the thumbs, and two round thumbs with soft accent halos that grow on hover/focus. Pressing anywhere on the track grabs the nearer thumb and drags it (pointer capture); thumbs can't cross (10-unit minimum gap). Each thumb is its own role=slider with arrows (Shift ×5) and descriptive aria-valuetext. The min/max values show below as mono chips joined by a hairline, with '+' when the max is at the top of the scale. 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 either thumb (or press on the track to jump the nearer one); arrows adjust the focused thumb. Motion: Bar colour 240ms as the range changes; thumb halo 200ms. Accessibility: Two role=slider thumbs with labels, bounds and value text; the result count is announced; the histogram is decorative. Reduced motion removes transitions. Responsive behavior: Fluid to 26rem; bars flex to fit. Touch: Press-and-drag anywhere on the track. 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 either thumb (or press on the track to jump the nearer one); arrows adjust the focused thumb.
Motion
Bar colour 240ms as the range changes; thumb halo 200ms.
Accessibility
Two role=slider thumbs with labels, bounds and value text; the result count is announced; the histogram is decorative. Reduced motion removes transitions.
Responsive
Fluid to 26rem; bars flex to fit.
On touch
Press-and-drag anywhere on the track.