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-compareThe preview stays free for everyone. Pro opens the code of every Pro component, screen, agent-app template, block and kit, plus the Pro CLI.
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.
oxyn add image-compareUsage
The preview is free. Pro opens the code of every Pro component, screen and template.
Examples
Slider
Drag the divider anywhere on the frame.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
Vertical
Top and bottom.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
Side by side
Both at once.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
Onion
After over before with an opacity slider.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
Difference
Difference blend: what changed lights up.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
API reference
ImageCompare
| Prop | Type | Default | Description |
|---|---|---|---|
beforerequired | Element | — | The original (left or top). |
afterrequired | Element | — | The result (right or bottom). |
position | Option<f32> | Default::default() | Controlled position, percent. |
default_position | f32 | 50.0 | Starting position. |
orientation | String | "horizontal" | `horizontal` · `vertical`. |
labels | Option<(String, String)> | Some(("Before".to_string(), "After".to_string())) | Captions (`None` hides them). |
label | String | "Before and after" | Divider's accessible name. |
aspect_ratio | String | "3 / 2" | CSS aspect ratio. |
mode | CompareMode | CompareMode::Slider | Compare mode. |
opacity | f32 | 0.5 | Onion-skin opacity of the after image, 0..1. |
on_position_change | EventHandler<f32> | — | The divider settled. |
Read from the Rust signature and doc comments.
Keyboard interactions
| Key | Action |
|---|---|
| Arrow keys | Move the divider 1 % (10 % with Shift) |
| Page UporPage Down | Move 10 % |
| HomeorEnd | All before / all after |
| Double-click | Recentre 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
ImageComparefromoxyn_dioxusand includeSTATUS_INDICATOR_CSSplus the token stylesheet once. - A GPUI version exists:
ImageCompareElinoxyn_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.