r/reactjs • u/hayderkg • 19d ago
Show /r/reactjs I built Detent, an open-source React wheel picker with spring physics, morphing text, and rolling numbers
I’ve just released Detent, a React wheel picker that grew into a much bigger exploration of interaction details.
The wheel has its own momentum and spring physics. I spent a lot of time tuning mouse wheel input alongside trackpads, including the awkward cases where a physical scroll wheel keeps spinning after you let go.
It also includes two separate components:
- Detent Text: matching letters stay while the changed parts roll.
- Detent Number: locale-aware formatting with digits that roll through intermediate values.
The examples range from practical time and date pickers to an arc menu, a zoom ring, and some more experimental visual treatments.
There’s a headless hook, separate imports for text and numbers, keyboard support, reduced motion, and no additional runtime dependencies beyond React and React DOM.
Demos and playground: https://detent.hayder.sh
Intro: https://x.com/kghayder/status/2118373654010466733?a=PzCQRSXhM5m8KUTdHk8&s=20
I’d especially appreciate feedback on how the wheel feels with your mouse or trackpad, and whether the API makes sense for something you’d actually build.
10
u/oldyoyoboy 19d ago
love the demo, very slick
3
u/Important_Pomelo_407 19d ago
Saw there was no demo video yet, so I made you one. Here’s the PR: https://github.com/hayderkg/detent/pull/1
and I used my repo to do it :) https://github.com/yasirwhite/OpenDemo
2
u/vkalahas 17d ago
Very obvious you're a senior design engineer based on the amount of polish. Great work!
2
u/BeatsByiTALY 19d ago
Really great work with a bunch of killer examples
2
u/andyfitz 19d ago
looks awesome mate, and you have me wanting to ditch my custom coverflow/ gallery switcher on lolly.tools to your component because you have it dialled in so well snap wise
1
u/nameupp 19d ago
the zero-dep headless hook setup with separate text and number subcomponents is super clean. the biggest subtle headache with wheel pickers in react is native overscroll containment; since synthetic onwheel is passive by default in modern chromium, you can't e.preventDefault() to block the parent page from rubber-banding unless you're imperatively binding a non-passive wheel listener on the ref. curious how you're handling boundary damping for free-spinning inertia wheels like the mx master, because hundreds of rapid wheel events hitting min/max bounds can easily cause the spring accumulator to oscillate wildly if momentum isn't aggressively clamped imo
5
u/[deleted] 19d ago
[removed] — view removed comment