Image Comparison

Interactively compare two images with a draggable slider to reveal differences.

Examples

Image Comparison Basic

Tidewell weekly report in the dark themeTidewell weekly report in the light theme

Image Comparison with hover

Tidewell weekly report in the dark themeTidewell weekly report in the light theme

Image Comparison with spring options

Tidewell weekly report in the dark themeTidewell weekly report in the light theme

Image Comparison with custom slider

Tidewell weekly report in the dark themeTidewell weekly report in the light theme

Installation

npx shadcn@latest add https://ui.ndekocode.dev/r/motion-image-comparison.json

Component API

ImageComparison

PropTypeDefaultDescription
childrenReact.ReactNodeImageComparisonImage components.
classNamestringundefinedOptional CSS class for styling the component.
enableHoverbooleanfalseControls whether hover effects are enabled.
springOptionsSpringOptions{ bounce: 0, duration: 0 }Options for customizing the spring animation.

ImageComparisonImage

PropTypeDefaultDescription
classNamestringundefinedOptional CSS class for styling the component.
altstringThe alt text for the image.
srcstringThe source URL of the image.
position'left' | 'right''left'The position of the image.

ImageComparisonSlider

PropTypeDefaultDescription
classNamestringundefinedOptional CSS class for styling the component.