Image Compare

PRO

Before/after comparison slider with pointer drag and full keyboard support. Works with image URLs or any ReactNode, supports horizontal/vertical orientation and optional autoplay.

Pro Features

Unlock advanced capabilities with the Pro version

Drag to Compare

Smooth pointer dragging with clip-path — zero layout thrash.

Two Orientations

Split left/right or top/bottom with a single prop.

Full Keyboard Support

Arrow keys, Shift steps and Home/End on an ARIA slider.

Autoplay Hint

Gentle in-view oscillation that stops on interaction.

Images or ReactNodes

Compare photos, layouts or live components interchangeably.

Accessible by Default

role=slider with live aria-valuenow and a visible focus ring.

Installation

Install via CLI

npx @moontra/moonui-cli add image-compare

Usage

Pro Required
Full-color version of the photo
Grayscale version of the photo
BeforeAfter

Examples

Horizontal (images)

PRO

Drag the handle, or focus it and use the arrow keys, to wipe between two images. The overlay is clipped with clip-path, so dragging never triggers layout.

Pro Required
Full-color version of the photo
Grayscale version of the photo
OriginalEdited

Vertical orientation

PRO

Set orientation="vertical" to split top/bottom instead of left/right. Arrow keys and the handle icon adapt automatically.

Pro Required
Full-color version of the photo
Grayscale version of the photo
TopBottom

Any ReactNode content

PRO

before and after accept arbitrary ReactNodes, not just image URLs — compare live components, layouts or gradients side by side.

Pro Required
Final design
Wireframe
v1v2

Autoplay

PRO

With autoplay the divider gently oscillates once the slider scrolls into view, hinting that it's interactive. It stops permanently on the first user interaction and is fully disabled under prefers-reduced-motion.

Pro Required
Full-color version of the photo
Grayscale version of the photo