Compare
v1.0.0
Features
A comparison component between two images with slide or drag interaction to compare before and after states.
Dependencies
framer-motion
lucide-react
Installation
Add this component to your project
CLI Installation
npx shadcn@latest add https://ui.authmate.xyz/registry/compare.jsonManual Installation
// 1. Install dependencies
npm install framer-motion lucide-react
// 2. Copy the component code to components/ui/compare.tsx
// 3. Add the following to your tailwind.config.js if not already present:
module.exports = {
content: [
"./components/**/*.{js,ts,jsx,tsx}",
// ... other paths
],
theme: {
extend: {
cursor: {
'ew-resize': 'ew-resize',
'ns-resize': 'ns-resize',
}
}
},
// ... rest of config
}
// 4. Usage example:
import { Compare } from "@/components/ui/compare"
export default function MyComponent() {
return (
<Compare
beforeImage="/before.jpg"
afterImage="/after.jpg"
beforeLabel="Before"
afterLabel="After"
direction="horizontal"
/>
)
}Props
Component properties and their types
beforeImagestring
default: ''
URL or path to the before image
afterImagestring
default: ''
URL or path to the after image
beforeLabelstring
default: 'Before'
Label for the before image
afterLabelstring
default: 'After'
Label for the after image
direction'horizontal' | 'vertical'
default: 'horizontal'
Direction of the comparison slider
initialPositionnumber
default: 50
Initial position of the slider (0-100)
showLabelsboolean
default: true
Show before/after labels
showHandleboolean
default: true
Show the drag handle
onPositionChange(position: number) => void
default: undefined
Callback when slider position changes
classNamestring
default: ''
Additional CSS classes
heightstring | number
default: '400px'
Height of the comparison container
disabledboolean
default: false
Disable interaction
Examples
4 different usage examples
Basic Image Comparison
import { Compare } from '@/components/ui/compare'
export default function Example() {
return (
<Compare
beforeImage="/placeholder.svg?height=400&width=600"
afterImage="/placeholder.svg?height=400&width=600"
beforeLabel="Original"
afterLabel="Enhanced"
/>
)
}Registry
View the component registry file
Live Preview
Interactive
4 examples available

Before
After