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…
…you meant Comparison Slider (Before-and-After Slider).
Anatomy — every part, named
- 1Divider line
clip-path: inset(…)“The thin vertical line between the two pictures” is the divider line, drawn exactly where the top picture is cropped.
- 2Drag 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).
| ARIA | role="slider" + aria-valuenow | on the handle, so the arrow keys move the split |
| CSS | clip-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" |