What it does
Image Compare stacks two pieces of media and clips the before layer at a percentage-based divider. Pointer dragging and click-to-position update the reveal continuously without adding an animation dependency.
Composition and API
Pass React nodes to before and after. Use defaultPosition for uncontrolled state or position and onPositionChange for controlled state. Configure step, labels, appearance, size, radius, and disabled behavior through typed props.
Common use cases
- Show photo retouching and color-grading results.
- Compare renovation, restoration, or landscaping progress.
- Reveal map layers, scans, renders, or product configurations.
- Review visual regressions and design implementation changes.
Accessibility
The divider exposes slider semantics with its current value, range, label, and disabled state. Arrow, Page, Home, and End keys provide precise operation without a pointer, while visible focus styling identifies the active control.
Next.js integration notes
The static component is a client entry because it manages pointer and keyboard interaction. It accepts Next.js Image components as before and after nodes, while the route can remain a Server Component and export static metadata.
FAQ
Can Image Compare be controlled from application state?
Yes. Pass position with onPositionChange for controlled usage, or defaultPosition for internal state. Values are clamped from 0 to 100.
Does the divider support keyboard controls?
Yes. Focus the divider and use Arrow keys for one step, Page Up or Page Down for ten steps, and Home or End for the limits.
Must the before and after content be img elements?
No. Both props accept React nodes, so they can contain responsive images, Next.js Image components, illustrations, maps, or any aligned visual content.
How do I customize its colors and dimensions?
Choose appearance, size, and radius variants, add a className for layout, or override the documented --zui-image-compare-* CSS variables.
