Introducing Motion-Primitives Pro - Advanced components and templates to help you build a website that stands out.

Image Comparison

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

Examples

Image Comparison Basic

Motion Primitives DarkMotion Primitives Light

Image Comparison with hover

Motion Primitives DarkMotion Primitives Light

Image Comparison with spring options

Motion Primitives DarkMotion Primitives Light

Image Comparison with custom slider

Motion Primitives DarkMotion Primitives Light

Installation

npx shadcn add "https://motion-primitives.com/c/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.