---
title: Image Compare
description: Interactive before-and-after image slider comparison component with keyboard and touch support.
---
Image Compare
Interactive before-and-after comparison slider with smooth drag handling, arrow key precision control, and responsive touch gestures.
Before & After Comparison
Original Theme (Light)
↔
JavaScript Initialization
import { ImageCompare } from 'boodoo';
const compare = new ImageCompare('#demoImageCompare', {
initialPosition: 50, // 50% split
orientation: 'horizontal'
});
Options & Events Reference
| Option / Event | Type | Default | Description |
|---|---|---|---|
initialPosition |
number |
50 |
Initial percentage split divider position across the comparison container. |
orientation |
'horizontal' | 'vertical' |
'horizontal' |
Divider drag direction and orientation mode. |
setPosition(percent) |
(percent: number) => void |
— | Programmatically repositions divider handle between 0 and 100. |
boodoo:compare:change |
CustomEvent |
— | Fired on drag movement with current split position. |