Overview
Reference usage
ImageCompare compares two screenshots of the same screen: side by side in panes that scroll together, or overlaid with a wipe the reader drags.
Usage
Side by side, each image is a figure captioned by its label and caption. The panes scroll together by pixel offset, so two screenshots of the same width stay row for row, and they stack once the container is too narrow for two columns. Images show at their natural size.
In the wipe mode the two overlap: before shows up to a divider and after beyond it. The reader drags the round handle with a pointer, or uses the "Wipe position" slider under the frame, whose ends and value text name the two images by label. position is bindable, from 0 (all after) to 1 (all before). offset shifts before by whole pixels to line the two up, and applies only in the wipe; build the nudge buttons from Button.
The page owns the mode switch (a SegmentedControl) and passes mode.
When to use
- Checking what changed between two versions of the same screen, such as two review rounds.
- Showing one large image to zoom and pan. Use Zoom Pan Viewer instead
Examples
Side by side
Two captioned panes that scroll together, so two screenshots of one screen stay row for row.
Wipe
The two images overlap; drag the handle or use the slider to move the divider between them.
Props
Name | Type | Default | Description |
|---|---|---|---|
before required | {
/** The image's URL. */
src: string;
/** The image's text alternative. */
alt: string;
/** A short name for the version, such as "Round 2". The wipe… Show full type{
/** The image's URL. */
src: string;
/** The image's text alternative. */
alt: string;
/** A short name for the version, such as "Round 2". The wipe's slider and its value text use it. */
label: string;
/** Words after the label in the side-by-side caption, such as "previous version". */
caption?: string;
} | The earlier image: the start pane side by side, the clipped layer in the wipe. | |
after required | {
/** The image's URL. */
src: string;
/** The image's text alternative. */
alt: string;
/** A short name for the version, such as "Round 2". The wipe… Show full type{
/** The image's URL. */
src: string;
/** The image's text alternative. */
alt: string;
/** A short name for the version, such as "Round 2". The wipe's slider and its value text use it. */
label: string;
/** Words after the label in the side-by-side caption, such as "previous version". */
caption?: string;
} | The later image: the end pane side by side, the full layer under the wipe. | |
mode | 'side-by-side' | 'wipe' | 'side-by-side' | side-by-side shows the two in panes that scroll together, stacked when the container is
narrow. wipe overlays them, with before shown up to a divider the reader drags. |
position bindable | number | 0.5 | The wipe's position, from 0 (all after) to 1 (all before): the share of the frame's width
that shows before. Bindable. Values outside 0 to 1 are clamped. |
offset bindable | { x: number; y: number } | How far before is shifted, in pixels, to line it up with after in the wipe. Side-by-side
panes are never shifted. Bindable. |