Skip to content

ButterIX v1 is out: versions, multiple languages, Ask AI, and a per-site MCP server, all built in. →

Image compare

<ImageCompare> stacks two images and lets you drag the divider left and right to compare them.

The two images sit on top of each other: before is left of the divider, after is right of it. Drag the handle or click anywhere on the image to move the divider; on phones, drag sideways to compare and swipe up or down to scroll the page as usual.

<ImageCompare
  before="/assets/media/compare-before.jpg"
  after="/assets/media/compare-after.jpg"
  beforeLabel="Low-res"
  afterLabel="High-res"
  alt="The same image in low and high resolution"
/>
The same image in low and high resolution · High-res
The same image in low and high resolution · Low-res

Both images should have the same aspect ratio; if they don't, after sets the size and before is cropped to fill it. The handle works with the keyboard: arrow keys move it 1%, with Shift 10%, and Home and End move it to either edge. When printed, the two images appear side by side.

beforeurlRequired
The image left of the divider (left also works).
afterurlRequired
The image right of the divider (right also works).
beforeLabelstring
Label in the top-left corner; fades out as the divider gets close.
afterLabelstring
Label in the top-right corner; fades out as the divider gets close.
altstring
Describes what the images compare; screen readers read it with the labels.
positionnumberDefault 50
Where the divider starts, in percent from the left (0–100).
widthstring
Display width: a number in pixels or a CSS length. Defaults to the full content width.