Before / After Slider
Drag, tap or use the arrow keys to wipe between two states. The knob stretches while held, the reveal edge glows and the handle sweeps once on first view.
Try it: Drag the handle, click to jump, or focus it and use ←/→ (Shift = ±10, Home/End).
Installation
Install with the shadcn CLI:
npx shadcn@latest add https://www.framekitui.live/r/before-after-slider.jsonOr, with the @framekit namespace registered: npx shadcn@latest add @framekit/before-after-slider. You can also copy the source into components/ui/before-after-slider.tsx (view on GitHub).
Usage
import { BeforeAfterSlider } from '@/components/ui/before-after-slider'Props
| Prop | Type | Default | Notes |
|---|---|---|---|
before / after | ReactNode | wireframe / polished mock | Layers to compare (images, nodes…). |
beforeLabel / afterLabel | string | 'Before' / 'After' | Corner labels. |
value / defaultValue | number | 50 | Position 0–100 (controlled / uncontrolled). |
onValueChange | (v: number) => void | — | Fires while moving. |
intro | boolean | true | Sweep once when scrolled into view. |
aspect | string | '16 / 10' | CSS aspect-ratio. |
className | string | — | Extra classes merged onto the root. |
Dependencies
motionlucide-react
Related Portfolio components
- Career Timeline
A vertical line that draws itself as you scroll with a glowing head; milestone nodes pop on springs and cards slide in from alternating sides.
- Case Study Scroll
Problem → Process → Result as a scroll-driven story: a sticky rail fills as you read and lights the current chapter while chapters rise in with staggered key figures.
- Skills Marquee
Two counter-rotating rails of skill pills. Hover or keyboard focus pauses, a visible Pause button covers touch and WCAG 2.2.2, and reduced motion becomes a calm wrapped list.
- Project Filter Gallery
Category chips share a sliding pill (layout animation) while the grid reflows: survivors glide to new cells, newcomers bloom in blur-to-sharp. Announces the result count.
- Skill Meters
Radial gauges that sweep to their value on scroll-in: glowing gradient arc, a comet dot on the tip and a live count-up. Staggered, replayable and exposed as ARIA meters.
- Project Reveal List
An editorial project index: rows dim their siblings and nudge on hover while a tilting preview chases the cursor on a spring and unmasks with a clip-path. Touch gets inline thumbnails.