Before and after slider
Drag the divider across a calendar to compare empty gap nights before with the same nights sold after.
The React code for this component comes with Pro.
Unlock with ProUse it for
- Showing the effect of a product on the same view
- Image edits, redesigns and data before and after a change
Avoid
- Two views that do not line up, which makes the comparison meaningless
- Small screens where the divider covers the detail
How it works
Both panels are stacked in the same box. The before panel is clipped with clip-path inset, whose right edge is driven by a --pos variable, and the handle is positioned from the same variable. Pointer down anywhere captures the pointer and every move writes --pos and aria-valuenow straight to the DOM, so there is no React render per frame.
Accessibility
The handle is a focusable element with role slider, a label, aria-valuenow and aria-valuetext. Arrow keys move it 5 percent (20 with Shift) and Home and End jump to the edges. touch-action pan-y lets phones scroll vertically while horizontal drags move the divider.
Get the source with Pro
The demo above is free to play with. Pro unlocks the source of this and every other Pro component, with copy-ready code and a zip download.
Already bought? Sign in- Pay once
Lifetime
Pay once, keep it forever.
$39once
- Every Pro component, with full source
- Lifetime updates: every future Pro component included
- One zip download, ready to drop into a React app
- Commercial use in unlimited client and personal projects