July 31, 2026
Deltaphoto
A small image comparison component for React. Give it two photos and it handles the rest.


I kept needing the same interaction: compare a redesign, show a restoration, explain an edit, or make a visual change obvious without asking someone to flip between two images. The available components worked, but most of them felt like unfinished plumbing rather than something I wanted to put on a page.
So I made the version I wanted to reach for: deliberately small, already designed, and useful without a setup screen full of decisions.
Getting started
The finished API is only two required props. Everything else is an optional refinement for a particular comparison.
npm install deltaphotoimport { Deltaphoto } from "deltaphoto";import "deltaphoto/styles.css";<Deltaphoto before="/room-before.jpg" after="/room-after.jpg"/>It fills the width of its parent and keeps a 3:2 aspect ratio by default. The component ships with its interaction styles, so the surrounding layout is entirely yours.
The interaction
The divider is built on a native range input, with a quick toggle control for switching between the two images. That means the same comparison works with a mouse, a finger, a trackpad, and a keyboard instead of maintaining a separate path for each one.
Drag anywhere
The full image is the target, not just the small handle.
Scroll naturally
It's mobile friendly, so it doesn't get in the way of touch screens when trying to scroll.
Keyboard stops
Arrow keys jump cleanly between the start, middle, and end.
Smooth drag
The divider beautifully eases toward where you dragged it.
Quick toggle
Instantly swap between the two images to quickly see the differences.
Making it yours
The defaults are meant to be the version you ship. The options are there for real content differences (labels, framing, and controlled state). Not for rebuilding the component piece by piece.
Try this playground to fill in the details you want to ship with. The codeblock below will update accordingly, so you can copy and paste that into your project.


import { Deltaphoto } from "deltaphoto";import "deltaphoto/styles.css";<Deltaphoto before="https://www.dannyohana.com/deltaphoto/miami-night.png" after="https://www.dannyohana.com/deltaphoto/miami-day.png" beforeAlt="Miami skyline at night" afterAlt="Miami skyline during the day" beforeLabel="Night" afterLabel="Day" ariaLabel="Compare the Miami skyline at night and during the day"/>Pass a class name or normal inline styles to the root when the comparison needs a different radius or surrounding treatment. Both images always share the same crop, which keeps the comparison visually honest.
Props
Images
beforestringrequired- URL for the image shown on the left.
afterstringrequired- URL for the image shown on the right.
Labels & accessibility
beforeAltstring"Before"- Alternative text for the before image.
afterAltstring"After"- Alternative text for the after image.
beforeLabelstring"Before"- Label shown over the before image.
afterLabelstring"After"- Label shown over the after image.
showLabelsbooleantrue- Show or hide both image labels.
ariaLabelstringcomparison description- Accessible name for the range control.
Position & state
initialPositionnumber50- Initial divider position from 0 to 100.
positionnumber—- Controlled divider position from 0 to 100.
onPositionChangefunction—- Runs whenever the divider moves.
Appearance
aspectRatioCSS value"3 / 2"- Aspect ratio of the comparison surface.
objectFitCSS value"cover"- How both images fit inside the surface.
foregroundColorCSS color"#000"- Color used for the grip and component text.
backgroundColorCSS color"#fff"- Color used for labels, the divider, and the handle.
Integration
classNamestring""- Class applied to the root element.
Standard div attributes, including data attributes and event handlers, are passed to the root element.
Package status
Deltaphoto is available as a public npm package for React. Install it with npm install deltaphoto, then import the component and its stylesheet into your app.
This page remains the source of truth for how the component is meant to work.