ArdoCompareSlider
Auf dieser Seite
Diese API-Referenz wird aus den englischen TypeScript-Quellkommentaren erzeugt. Namen, Signaturen und Beispiele entsprechen dem veröffentlichten Paket.
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
| Name | Type | Required | Description |
|---|---|---|---|
label | string | Yes | What the two sides show, such as "Class diagram". Names the slider for screen readers. |
first | ReactNode | Yes | Shown left of the divider. |
firstLabel | string | Yes | Name of the first side, such as "Before". |
second | ReactNode | Yes | Shown right of the divider. |
secondLabel | string | Yes | Name of the second side, such as "After". |
initial | number | No | Where the divider starts, in percent of the width from the left. Defaults to 50. |
className | string | No | Additional 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"
/>