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.

Frontwell redesigned: “Your front desk, handled.”
Frontwell's template homepage, with a 17-word headline
BeforeAfter

Install

npx shadcn add@easeout/spring-slider

Dependencies

motiontailwindcss

Tags

MediaFree componentMIT

Usage

After installing, it lives at components/spring-slider.tsx

app/example.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

PropTypeDefaultWhat it does
beforeReactNode–What sits on the left of the handle.
afterReactNode–What sits on the right.
initialnumber50Start position, 0 to 100.
labelstring"Compare before and after"Accessible name of the slider.
autoplaybooleanfalseGlides between a few positions until someone points at it, drags it or focuses it.
effectsbooleantrueThe 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.
classNamestring–Classes for the slider.

Want a whole page built like this?