r/react • u/hayderkg • 26d ago
OC 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.
3
u/rryyqn 26d ago
UI components are smooth and they look clean, I'll try it sometime. Could the weight dial have the number update as you move it, rather than update after the dial stops moving?
2
u/OkCommunity6018 26d ago
look very nice, thanks
1
u/sCREAMINGcAMMELcASE 23d ago
For shits and giggles you should add a rotatory phone input
1
u/Slappatuski 25d ago
Why do people think that we need even more UI libraries? there are millions of them already
on the other hand I cannot find libraries that solve more niech problems in an efficient way
2
u/ggGeorge713 26d ago
Wow, I'm. blown away! This just feels... right. It's so satisfying!
Love all the use cases you are showing!
You, sir, created something beautiful here. Well done!
1
u/raks1991 20d ago
Small screen-reader detail from dist/index.cjs (0.1.4): the listbox only renders the rows in the current window (visible plus overscan) and the selected one, and the options have no aria-setsize or aria-posinset. Browsers compute set size from the options present in the DOM, so on a 60-item minutes wheel a screen reader that reads position would likely give the count of mounted rows, not 60. I haven't checked it with VoiceOver or NVDA. Adding
aria-setsize={count}andaria-posinset={index + 1}to each option should fix it; in loop mode use the wrapped item index, not the virtual row.