js-cloudimage-before-after

Image Before After

Interactive image comparison slider with zoom & pan, drag/hover/click modes, and full accessibility. Zero dependencies, under 12 KB gzipped.

<12 KB Zero Dependencies TypeScript React WCAG 2.1 AA

Up and running in under a minute

Install from npm or load from CDN — choose the method that fits your workflow.

Try it live Vanilla React
Install via npm
npm install js-cloudimage-before-after
import CIBeforeAfter from 'js-cloudimage-before-after';

new CIBeforeAfter('#my-slider', {
  beforeSrc: '/before.jpg',
  afterSrc: '/after.jpg',
});
Use via CDN
<script src="https://cdn.scaleflex.it/plugins/js-cloudimage-before-after/1.0.0/js-cloudimage-before-after.min.js"></script>

<div
  data-ci-before-after-before-src="/before.jpg"
  data-ci-before-after-after-src="/after.jpg"
></div>

<script>CIBeforeAfter.autoInit();</script>

Interaction Modes

Choose how the slider responds: drag for precision, hover for preview, or click for quick comparison.

Drag

Click and drag the handle to compare images.

👁 Hover

Move the mouse over the image to reveal.

👆 Click

Click anywhere to set the comparison point.

Orientations

Compare images side-by-side or top-to-bottom.

Horizontal

Vertical

Light & Dark Themes

Built-in light and dark themes with full CSS custom property support.

Light (Default)

Dark

Zoom & Pan

Hold Ctrl (or ) + scroll to zoom. Drag to pan when zoomed in.

Interactive Configurator

Toggle options and see the generated code update in real time.

Preview

Options

Generated Code

js-cloudimage-hotspot

Add interactive hotspots to any image with zoom, popovers, and full accessibility. Zero dependencies, under 10 KB gzipped.

js-cloudimage-360-view

Interactive 360° product views with drag, zoom, autoplay and hotspots. Perfect companion for e-commerce showcases.