@gfazioli/mantine-compare
Mantine Compare is a responsive side‑by‑side comparison container that lets you render two pieces of content (images or custom React nodes) with consistent styling, layout controls, and accessibility.
Installation
After installation import package styles at the root of your application:
You can import styles within a layer @layer mantine-compare by importing @gfazioli/mantine-compare/styles.layer.css file.
Usage
The Compare is interactive component that allows you to compare two content sections by dragging a slider. It is particularly useful for visualizing differences between two versions of data.
Before (leftSection)
After (rightSection)
With Image Content
You can use the Compare component to compare two images by passing Image components as the leftSection and rightSection props.
Angle
Use angle to control the divider orientation.
angle={0}behaves like the previous vertical direction (left/right compare)angle={90}behaves like the previous horizontal direction (top/bottom compare)- Any value between
0and360creates an oblique (diagonal) divider
Diagonal angle
Set angle to any value between 0 and 360 to get an oblique divider.
Variants
The Compare component supports three interaction variants:
Drag variant (default)
The default variant="drag" allows users to click and drag the slider button to compare content.
Hover variant
Set variant="hover" to reveal content by moving the mouse over the component. The slider button is hidden in this variant.
Fixed variant
Set variant="fixed" to display a static comparison at a specific position. The slider button is hidden and users cannot interact with the slider. Use defaultPosition to control the split position.
Before
After
Styles API
Compare supports Styles API, you can add styles to any inner element of the component with classNames prop. Follow Styles API documentation to learn more.
You can customize the appearance of the Compare component using the Styles API. This allows you to modify styles for various parts of the component, such as the slider, sections, and container.
Before
After
Component Styles API
Hover over selectors to highlight corresponding elements