Component reference

Compare Slider

Two versions of anything, one over the other. Drag the divider, click to jump, or use the arrow keys.

Release card100 / 0
<CompareSlider variant="minimal" />Clean surfaces and measured motion.

Installation

Use the shadcn CLI to copy the component source and its dependencies into your own project. Only the Minimal world, with motion, plus the Ovio theme, world, motion items.

npx shadcn add JanaSundar/ovio/compare-slider-minimal
↳You own the source. Ovio components arrive in your codebase so you can edit any part of their style, behavior, or data flow.

Usage

Set the visual world on the component, or wrap the page in an OvioProvider to set a default for everything inside it.

TSXvariant="minimal"
import { CompareSlider } from "@/components/ovio/compare-slider/compare-slider"

<CompareSlider
  variant="minimal"
  before={<img src="/v1.png" alt="" />}
  after={<img src="/v2.png" alt="" />}
/>

Built with: CSS clip-path · Motion for React (spring, drag; Retro: stepped)
Motion in Minimal: Small springs, opacity and layout shifts that show state.

Props

Control the data, selected world, animation behavior, and callbacks.

PropTypeDescription
before / afterReactNodeThe two versions, left and right of the divider. Images fill the view.
variantdefault minimalminimalcraftretrotoyWhich world to render. Uses the nearest OvioProvider when there is one.
beforeLabel / afterLabeldefault "Before" / "After"stringPrinted in the top corners; each fades as the divider covers it.
value / defaultValuedefault 50numberHow much of before shows, 0–100. Controlled, or the starting split.
onValueChange(value: number) => voidFires while dragging.
labeldefault "Compare"stringAccessible name for the divider.
aspectRatiodefault "4 / 3"stringCSS aspect ratio of the view.
classNamestringMerged onto the root.