Easeout LabSpring Compare Slider
Spring Compare Slider
A before/after slider on a spring. While it moves, the divider bends with its speed, the old side crumbles into pixels and sparks fly off the line.


Install
npx shadcn add@easeout/spring-sliderDependencies
motiontailwindcss
Tags
MediaFree componentMIT
Usage
After installing, it lives at components/spring-slider.tsx
import { SpringSlider } from "@/components/spring-slider"
export default function Example() {
return (
<SpringSlider
className="w-full max-w-2xl"
label="Compare the old and new homepage"
before={<img src="/before.webp" alt="Old homepage" className="h-full w-full object-cover" />}
after={<img src="/after.webp" alt="New homepage" className="h-full w-full object-cover" />}
/>
)
}
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
before | ReactNode | – | What sits on the left of the handle. |
after | ReactNode | – | What sits on the right. |
initial | number | 50 | Start position, 0 to 100. |
label | string | "Compare before and after" | Accessible name of the slider. |
autoplay | boolean | false | Glides between a few positions until someone points at it, drags it or focuses it. |
effects | boolean | true | The bend, the crumbling old side and the sparks. Always off for reduced motion. |
labels | [string, string] | false | ["Before", "After"] | Corner tags for the two sides; false hides them. |
className | string | – | Classes for the slider. |