Comparison Slider
Interactive before-and-after image comparison with pointer, touch, and keyboard controls.


Installation
Usage
import { ComparisonSlider } from "@/components/ui/comparison-slider"
<ComparisonSlider beforeImage="/images/before.jpg" afterImage="/images/after.jpg" initialPosition={50} />
Props
PropTypeToggle
Notes
- Drag or click anywhere across the image to move the divider.
- Keyboard users can focus the slider and use
ArrowLeft,ArrowRight,Home, andEnd. - The
initialPositionvalue is clamped between0and100.