Diff

A component for comparing two images with a draggable slider

Default
Interactive controls for image URLs, slider position, labels, and layout classes
Drag the slider to compare
50% / 50%
1<Diff
2 beforeImage="https://placehold.co/1600x900?text=Before"
3 afterImage="https://placehold.co/1600x900?text=After"
4 initialPosition={50}
5 showPercentage
6 showInstructions
7 className="w-full max-w-5xl h-[450px]"
8/>

Controls

beforeImage
afterImage
initialPosition
showPercentage
showInstructions
className
Custom Size
Interactive custom-size preset that users can tweak live via controls
Drag the slider to compare
40% / 60%
1<Diff
2 beforeImage="https://placehold.co/1400x900?text=Before"
3 afterImage="https://placehold.co/1400x900?text=After"
4 initialPosition={40}
5 showPercentage
6 showInstructions
7 className="w-full max-w-2xl h-[380px]"
8/>

Controls

beforeImage
afterImage
initialPosition
showPercentage
showInstructions
className

Props

NameTypeDefaultDescription
beforeImagestringhttps://placehold.co/800x600The base image shown before comparison
afterImagestringhttps://placehold.co/800x600The overlay image revealed by the slider
initialPositionnumber50The initial position of the diff slider
showPercentagebooleantrueWhether to show the percentage of the diff
showInstructionsbooleantrueWhether to show the instructions for the diff
classNamestringw-full max-w-5xl h-[450px]Tailwind classes for styling the diff component