Compare Slider
ProA before/after reveal with a draggable, keyboard-operable handle.
Installation
pnpm dlx shadcn@latest add @viewport/compare-slider
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
The code behind the preview above comes with Truffle Pro.
Props
| Prop | Type | Default |
|---|---|---|
| before* | React.ReactNode | — |
| after* | React.ReactNode | — |
| defaultValue | numberStarting position, 0 to 100. | 50 |
| label | stringAccessible name for the handle. | "Comparison position" |
| className | string | — |
Accessibility
- The handle is a real role=slider.
- Arrow keys move it, Shift moves faster, Home and End jump.
- Vertical page scrolling still works on touch.