Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Compare Slider

Pro

A before/after reveal with a draggable, keyboard-operable handle.

Installation

pnpm dlx shadcn@latest add @viewport/compare-slider

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above comes with Truffle Pro.

Props

PropTypeDefault
before*React.ReactNode—
after*React.ReactNode—
defaultValuenumber

Starting position, 0 to 100.

50
labelstring

Accessible name for the handle.

"Comparison position"
classNamestring—

Accessibility

  • The handle is a real role=slider.
  • Arrow keys move it, Shift moves faster, Home and End jump.
  • Vertical page scrolling still works on touch.