Skip to content
Uxelith
Sign in
Prov1.0.0Cards

Compare Slider

Two layers split by a glass handle you drag, or that follows the pointer. A press glides the divider there on a spring, a double-click sends it home; optional feathered seam, vertical split and first-view sweep.

Installs with Uxelith ProHow
Licence
Pro
Packages
3
Updated
9 Oct 2026
Live

Installation

Usage

example.tsx
import Image from "next/image"

import { CompareSlider } from "@/components/compare-slider"

export function Retouch() {
  return (
    <CompareSlider
      label="Compare original and retouched photo"
      beforeLabel="Original"
      afterLabel="Retouched"
      before={<Image src="/original.jpg" alt="Original photo" width={1200} height={800} />}
      after={<Image src="/retouched.jpg" alt="Retouched photo" width={1200} height={800} />}
    />
  )
}

Props

PropTypeDefaultDescription
before / afterReactNode—The two layers, same size. Images or any UI.
beforeLabel / afterLabelstring—Corner captions that fade as the divider reaches them; also used in the announced value.
value / defaultValuenumber— / 50Divider position in percent.
onValueChange(value: number) => void—Called while dragging or using keys.
labelstring"Comparison divider"Accessible name of the handle.
--compare-dividerCSS variablewhiteDivider and glow colour. The position is also exposed as --compare-position.
mode"drag" | "hover""drag"Drag while pressed, or follow the mouse without a press (touch still drags).
orientation"horizontal" | "vertical""horizontal"Side by side, or top and bottom.
feathernumber0Soften the seam over this many pixels instead of a hard cut.
hintbooleanfalseSweep the divider once on first view (uncontrolled only).

Accessibility

  • The handle is role="slider" with min, max, now and a readable value ("46% Light, 54% Dark").
  • ←/→ move 1%, Page Up/Down 10%, Home/End jump to the edges.
  • A double-click returns the divider to its starting position; the keyboard reaches every position too.
  • Drag with mouse, pen or touch; vertical page scrolling still works on phones.
  • Both layers stay in the accessibility tree, so image alt text is read.
  • Keyboard moves are instant; the first-view sweep never runs under prefers-reduced-motion or after someone has touched the slider.

Changelog

  1. v1.0.0Latest

    First release.

More in Cards

All 6 in Cards
  • CardsPro

    Card Stack

    A deck you throw cards from: the top card leans from where you grabbed it and flies off with the speed you gave it, the rest rise to take its place, and Undo brings it back. Keys and buttons too.

  • CardsPro

    Morph Card

    A card that grows into its own story: the photo, eyebrow and title fly to their places, and you pull the story down to fold it back into the grid. Built on the native modal dialog.

  • CardsFree

    Pricing Card

    One plan in a pricing table, set large: a price that rolls when billing changes, a highlighted plan on a dark surface lit by your accent, and features read as included or not.