CompareSlider

Before/after reveal. Drag the divider; the top layer follows on a spring. It sweeps once to show it moves. Effects.

Open playground
After
Before

About

CompareSlider is a React component in the Effects category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { CompareSlider } from "@ashutoshswamy/smoui" and set before, defaultValue.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { CompareSlider } from "@ashutoshswamy/smoui";

<CompareSlider before={<img src="/before.jpg" alt="" />} after={<img src="/after.jpg" alt="" />} />

Props 2

before / after

The two layers. They should fill their box.

ReactNode
defaultValue

Starting position, 0-100. Arrow keys move it.

numberdefault 50