Skip to content
⌘K

ArdoCompareSlider

On this page

Two views of the same size laid over each other and split by a divider, such as a screenshot before and after a change. The first shows left of the divider and the second right of it.

Built on react-compare-slider. The pointer and the arrow keys move the divider. On a touch screen only the handle drags it, so a swipe elsewhere on the comparison still scrolls the page. The prerendered page shows the divider at its start position; it moves once the page hydrates.

import { ArdoCompareSlider } from "ardo/ui"

<ArdoCompareSlider
  label={…}
  first={…}
  firstLabel={…}
  second={…}
  secondLabel={…}
/>

Props

NameTypeRequiredDescription
labelstringYesWhat the two sides show, such as "Class diagram". Names the slider for screen readers.
firstReactNodeYesShown left of the divider.
firstLabelstringYesName of the first side, such as "Before".
secondReactNodeYesShown right of the divider.
secondLabelstringYesName of the second side, such as "After".
initialnumberNoWhere the divider starts, in percent of the width from the left. Defaults to 50.
classNamestringNoAdditional CSS class.

Props type: ArdoCompareSliderProps

Example

<CompareSlider
  label="Sign-in page"
  first={<img src="/before.png" alt="Sign-in page before the redesign" />}
  firstLabel="Before"
  second={<img src="/after.png" alt="Sign-in page after the redesign" />}
  secondLabel="After"
/>