Comparison Slider
Web (React)
Two layers stacked, with a divider the user drags to compare them.
A buttery smooth, accessible image/layer comparison slider. It supports both horizontal and vertical orientations and is fully keyboard navigable.
Light Mode
Dark Mode
Installation
CLI
npx @modus-ui/cli add comparison-sliderManual
- Copy the code from the component tab.
- Create a file at
components/ui/comparison-slider.tsx. - Paste the code.
Usage
tsx
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| before | ReactNode | - | The layer revealed on the leading side of the divider. |
| after | ReactNode | - | The layer underneath, revealed as the divider moves across it. |
| defaultPosition | number | 50 | Where the divider starts, 0 to 100. |
| orientation | "horizontal" | "vertical" | "horizontal" | The orientation of the slider. |
| label | string | "Compare before and after" | Accessible name for the divider. |
| className | string | "" | - |
Comments