Skip to content
Back

Image comparePro

Two images under one divider to see what changed: drag anywhere, arrow keys and Home / End, double-click to recentre; plus side by side, onion skin and a difference blend.

oxyn add image-compare
The code is part of Oxyn Pro

The preview stays free for everyone. Pro opens the code of every Pro component, screen, agent-app template, block and kit, plus the Pro CLI.

Get Pro

Rendered from Rust at build time · goes live when visible

When to use

  • Before and after visuals: a retouch, a redesign, a screenshot an agent changed.
  • Two stacked images, the before clipped at the divider (clip-path: inset).
  • Drag anywhere on the frame; keys move the divider (compare_key); captions fade as the divider reaches them (caption_opacity).
  • Oxyn plus: side by side, onion skin with an opacity slider and a difference blend.

When not to use

  • A launch countdown with digits that roll per unit, a compact one-line variant, hours absorbing days when days are hidden, and a live state with a pulsing dot at zero: use Countdown instead.
  • A total that moves clearly: use Animated counter instead.
  • A collapsible JSON tree with search, paging for long arrays, copy value or path, the current path under the tree and full keyboard moves: use JSON viewer instead.

Installation

Image compare is part of Oxyn Pro; the preview is free. Pro items install with the oxyn CLI once your licence is signed in; until then Pro members copy the code from this page.

Terminal
oxyn add image-compare

Usage

Dioxus · rust
The code is part of Oxyn Pro

The preview is free. Pro opens the code of every Pro component, screen and template.

Get Pro

Examples

Slider

Drag the divider anywhere on the frame.

Code Pro
The code is part of Oxyn Pro

The preview is free. Pro opens the code of every Pro component, screen and template.

Get Pro

Vertical

Top and bottom.

Code Pro
The code is part of Oxyn Pro

The preview is free. Pro opens the code of every Pro component, screen and template.

Get Pro

Side by side

Both at once.

Before
After
Code Pro
The code is part of Oxyn Pro

The preview is free. Pro opens the code of every Pro component, screen and template.

Get Pro

Onion

After over before with an opacity slider.

Code Pro
The code is part of Oxyn Pro

The preview is free. Pro opens the code of every Pro component, screen and template.

Get Pro

Difference

Difference blend: what changed lights up.

Changed areas light up
Code Pro
The code is part of Oxyn Pro

The preview is free. Pro opens the code of every Pro component, screen and template.

Get Pro

API reference

ImageCompare

PropTypeDefaultDescription
beforerequiredElement—The original (left or top).
afterrequiredElement—The result (right or bottom).
positionOption<f32>Default::default()Controlled position, percent.
default_positionf3250.0Starting position.
orientationString"horizontal"`horizontal` · `vertical`.
labelsOption<(String, String)>Some(("Before".to_string(), "After".to_string()))Captions (`None` hides them).
labelString"Before and after"Divider's accessible name.
aspect_ratioString"3 / 2"CSS aspect ratio.
modeCompareModeCompareMode::SliderCompare mode.
opacityf320.5Onion-skin opacity of the after image, 0..1.
on_position_changeEventHandler<f32>—The divider settled.

Read from the Rust signature and doc comments.

Keyboard interactions

KeyAction
Arrow keysMove the divider 1 % (10 % with Shift)
Page UporPage DownMove 10 %
HomeorEndAll before / all after
Double-clickRecentre the divider

Accessibility

  • The divider is a focusable role=slider with aria-orientation and aria-valuetext like “40% after”.
  • Captions are aria-hidden; give both images real alt text.
  • Reduced motion moves the divider and handle without the stretch or bump.
From the spec
  • role=slider with aria-orientation, aria-valuenow and aria-valuetext "40% after"; captions aria-hidden; images need their own alt.

Motion & interaction

Timing
  • The divider follows the pointer directly; the knob stretches to 18×40 px over 180 ms while dragging.
  • An edge key press gives a 200 ms bump; captions fade over 150 ms.
  • Reduced motion: no stretch or bump.

Responsive behaviour

  • Full width at a fixed aspect ratio; on touch a vertical swipe still scrolls the page.
Edge cases (spec)
  • Full width at a fixed aspect ratio; touch-action pan-y keeps vertical page scroll on touch (pan-x when vertical).

Notes for AI

  • Import ImageCompare from oxyn_dioxus and include STATUS_INDICATOR_CSS plus the token stylesheet once.
  • A GPUI version exists: ImageCompareEl in oxyn_gpui.
  • Props to set first: before, after.
  • Keep its states and timings as they ship; restyle it through the CSS variables rather than by hand.

Guides

Oxyn · 74 free components · 264 Pro components · 96 screens · 20 blocks · Dioxus and GPUI