SponsorYour name here · $500/mo
After
Revenue
$48.2k+12%
Weekly
Before

Drag the round handle, or click either side: the line it rides is the divider line

Comparison Slider (Before-and-After Slider)

/ role="slider" + aria-valuenow · clip-path: inset(0 48% 0 0) /

also called before and after slider, image comparison slider, curtain slider, before-after reveal

“Two pictures on top of each other with a line you drag across” is a comparison slider, also called a before-and-after slider (react-compare-slider's ReactCompareSlider, or the img-comparison-slider custom element). Both pictures sit in the same spot at full size and the top one is cropped at the line (CSS clip-path), so dragging the round handle wipes one away to show the other: a retouched photo, a redesign, a map then and now. Clicking either side moves the line there, and the arrow keys nudge it. It is not a carousel, which swaps whole slides, nor a slider that picks a number, though the handle borrows that role.

If you called it…

“two pictures on top of each other with a line you drag to reveal the other one”“the slider in the middle of the overlaid images”“the circle in the middle that you drag between the two images”“drag the bar left and right to see the old design and the new one”“one photo wipes away as you pull the handle across it”“one image split down the middle showing two versions”

…you meant Comparison Slider (Before-and-After Slider).

Anatomy — every part, named

  1. 1
    Divider lineclip-path: inset(…)

    “The thin vertical line between the two pictures” is the divider line, drawn exactly where the top picture is cropped.

  2. 2
    Drag handle (knob)role="slider"

    “The circle with two arrows in the middle” is the drag handle, the round knob on the line that you drag or nudge with the arrow keys.

Prompt — paste into your agent

Build a comparison slider, also called a before-and-after slider (react-compare-slider's ReactCompareSlider, or the img-comparison-slider custom element): two pictures stacked at the same size, the top one cropped with clip-path: inset() at a thin vertical line that carries a round handle. Dragging the handle or clicking either side moves the line; the handle is role="slider" with aria-valuenow, so the arrow keys work too. Crop the top picture, never resize or squish it.

Debug prompt — when it misbehaves

Paste this, then describe what you’re seeing — it hands your agent the classic failure modes to rule out first.

Debug my comparison slider (clip-path: inset(), role="slider", pointer events, setPointerCapture). Rule out: the top picture squishing because its width is animated instead of being cropped with clip-path; the two pictures laid out at different sizes or object-fit, so nothing lines up at the line; the drag dying when the pointer leaves the handle because the pointer was never captured; the browser dragging a ghost of the image because draggable was left on; the page scrolling sideways on phones because touch-action is not set; the handle lagging behind the finger because a CSS transition runs during the drag; the arrow keys doing nothing because the handle has no role="slider" or tabindex. The symptom:

In code

The exact names this thing goes by in code — each row is one framework’s word for it. Use the row that matches your project (or paste it into your prompt).

ARIArole="slider" + aria-valuenowon the handle, so the arrow keys move the split
CSSclip-path: inset(0 48% 0 0)crops the top picture at the line without squishing it
react-compare-slider<ReactCompareSlider itemOne={…} itemTwo={…} />takes any two React nodes, not only images
img-comparison-slider<img-comparison-slider>a custom element; the pictures go in slot="first" and slot="second"

See also

From the maker of this site48h Icons · Custom Apple app icons in 48 hours