Breaking Changes
positionprop renamed todefaultPositionuseReactCompareSliderRefremoved - useuseReactCompareSliderContextinstead- Handle now uses
--rcs-handle-colorCSS variable for default colour instead ofcolorinline style - Components no longer wrapped in
forwardRef(refs still work as props in React 19) - Slider width no longer defaults to
100%- uses intrinsic content size instead onlyHandleDraggabledefaults totruefor touch devices andfalsefor non-touch devices- Node 20 is now the minimum supported version
Features
- New
clipproperty - acceptsitemOne,itemTwo, orallto control which items are clipped; useful for content with alpha backgrounds, closes #136 thanks to @zoltan-mihalyi for working on this itemTwois no longer absolutely positioned; both items' sizes are now factored into slider sizing- Props moved to context and exposed via
useReactCompareSliderContexthook, enabling fully bespoke slider implementations #180 - Individual components and the
useReactCompareSliderhook now exported for building custom sliders with full control over internal props and callbacks #180, helps #158 transitionnow defaults to0.15s ease-outwhen user does not haveprefers-reduced-motion: reducedonlyHandleDraggablenow defaults totruefor touch devices andfalsefor non-touch devices via thepointer: coarsemedia query- High contrast support added to the default slider handle #175
- Slider root element changed from
buttontodivfor improved accessibility #156 - CSS variables now used for bounds padding and positioning instead of JS #160
- Const objects exported for easy CSS variable access
Fixes
- Touch devices now correctly disconnect on
touchend - CJS version now published, resolving Jest issues, closes #144
- Slider sets
touch-action: pan-yinstead oftouch-action: none, allowing scroll-past on touch devices, closes #134 - Removes tap highlight styles from handle on iOS #161
Performance
- CSS positioning is applied via CSS Houdini property to keep slider position and clip paths in sync across browsers
- Transition is smooth even on very low end devices
Other
- Upgrades to Storybook v10 using Vitest Playwright test runner
- Improves testing of components
- Moves server component tests to a Storybook server component test
- Moves from ESLint and Prettier to Biome
- Documents all exposed properties
- Uses Sonar for code coverage and reporting
- Adds React Doctor to CI
Full Changelog: v3.1.0...v4.0.0