Build a dual-handle range slider as a single React component. The user drags two circular handles along a track to pick a low and a high value between 0 and 100; the segment between them is highlighted and a label reads the current range. The interesting part isn't the markup — it's turning a raw pointer position into a clean integer value, and stopping the two handles from crossing each other.
The starter App.tsx renders the track, the highlighted range, both handles, and the 20 – 80 label in a resting state with no drag logic. Make it interactive:
low and high in useState (start 20 / 80) and grab the track element with a useRef.onPointerDown, add pointermove and pointerup listeners on window (not the handle) so the drag keeps working even when the pointer leaves the handle.pointermove, read the track's getBoundingClientRect() and compute round((e.clientX - rect.left) / rect.width * 100), clamped to 0..100.low to min(value, high) and high to max(value, low).pointerup, remove both window listeners.20 – 80 below. Dragging the left handle right to the middle updates the label to 50 – 80 and shrinks the green bar.window.window, not the handle. A fast drag outsprints the handle; window-level pointermove/pointerup keep tracking until release.Math.round on the percentage gives whole-number values and a tabular label that doesn't jitter.low can't exceed high and high can't fall below low — that's the whole "range" guarantee.styles.css; focus on the state and the pointer math.