r/react • • 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.

108 Upvotes

12 comments sorted by

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?

1

u/hayderkg 25d ago

Great! I’m glad you like it. And yes, the addition to the weight dial definitely makes perfect sense. It also helped me identify a small bug in "Detent Number," which has now been fixed in v.0.1.3. You can see it now in prod.

tysm, u/rryyqn!

2

u/OkCommunity6018 26d ago

look very nice, thanks

2

u/hayderkg 25d ago

Thanks a lot for the comment! I’ll keep refining it and will share updates on X https://x.com/kghayder

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/hayderkg 25d ago

100% agree, and that's kind of the point of Detent. It's not another UI kit and it does solves one niche problem with the iOS-style wheel picker, which is surprisingly hard to get right on the web: real momentum and snapping, keyboard and screen reader support, SSR, touch and mouse wheel (with a response practically identical to a trackpad), all in a few kB. If you need that, there wasn't really a good option, so I built it with Detent :)

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} and aria-posinset={index + 1} to each option should fix it; in loop mode use the wrapped item index, not the virtual row.