Skip to content

Replace react-slider with Radix slider - #2078

Open
NAThompson wants to merge 1 commit into
silx-kit:mainfrom
NAThompson:feat/radix-slider
Open

NAThompson wants to merge 1 commit into
silx-kit:mainfrom
NAThompson:feat/radix-slider

Conversation

@NAThompson

Copy link
Copy Markdown
Contributor

Replaces the unmaintained react-slider (React ≤18 peer) with @radix-ui/react-slider in DomainSlider and SlicingSlider, keeping the same look, props and behaviour, with new pointer and keyboard tests. Lets #2074 drop its react-slider peer exemption.

Before: domain slider (react-slider) After: domain slider (Radix)
Before: slicing sliders After: slicing sliders

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@axelboc

axelboc commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Awesome, thank you! Been meaning to do this for a long time. Any difference in bundle size?

@NAThompson

Copy link
Copy Markdown
Contributor Author

Thanks! The demo bundle grows by 5.8 kB gzipped (+0.4%), mostly from Radix's small helper packages; @h5web/lib's own dist grows by 2 kB.

@axelboc

axelboc commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Okay, that's not huge but it's not negligible either. I also notice a bit of complexity related to Radix offsetting the thumbs to keep them within the bounds of the slider track, and a whole chunk of code to take over the interaction (startInteraction, endInteraction) maybe because Radix swaps the thumbs instead of pushing them? Not entirely sure but not great either way.

Would you consider trying another implementation with the Base UI slider to compare?

In the field of UI-less React components, I also know of React Aria's slider but the thumbs don't push each other when dragged, which isn't as nice, so I've discarded it. If Claude has other suggestions that lead to a simple and lightweight implementation, I'm all ears.

@NAThompson

Copy link
Copy Markdown
Contributor Author

@axelboc : I'm setting my claude on doing three implementations in different PRs-feel free to pick the one you like best and close the others.

@NAThompson

Copy link
Copy Markdown
Contributor Author

Thanks, good call. I tried Base UI and also a dependency-free version, both as draft PRs for side-by-side comparison:

  • Replace react-slider with Base UI slider #2088 Base UI removes both things you spotted: thumbs are centred by default (no offset correction) and they push rather than swap (no startInteraction/endInteraction). However, it's heavier than Radix (+8.0 kB gzipped vs +5.9 kB), with the keyboard a thumb stops at the other instead of pushing it, and every key press is committed.
  • Replace react-slider with a built-in slider #2087 Built-in slider (~200 lines: pointer, keyboard, ARIA, pushing) makes the demo bundle 2.8 kB smaller gzipped and adds no dependencies. It keeps react-slider's behaviour (pushing with pointer and keyboard, commit on key release).

The comparison table is in both PRs, and all three carry the same new tests. My preference is the built-in one, but happy to go with whichever you'd rather maintain.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants