Skip to content

pastetaste

Before / After Compare

MediaInteraction

Two photographs from the same viewpoint with a draggable handle that wipes the before picture away; pointer drag anywhere or keyboard arrows on a real range input.

Paste it into Claude Code: it installs the component, asks for your brand and content, and places it on the page you name.

Install

Or by hand, in a Next.js project with shadcn set up. It writes components/pastetaste/before-after-compare.tsx.

npx shadcn@latest add https://pastetaste.com/r/before-after-compare.json

Prompt

Install the pastetaste component "Before / After Compare" (before-after-compare) into this Next.js project and use it.

What it is: Two photographs from the same viewpoint with a draggable handle that wipes the before picture away; pointer drag anywhere or keyboard arrows on a real range input.

Before you place it, ask me (one short message, in my language; "skip" = sensible default): which page and section it goes in, my brand colour (hex), the text, labels or images it should show, and whether I want my logo or my own copy in the demo content. Then:

Steps:
1. If the project has no components.json, run: npx shadcn@latest init -y -d. Then run: npx shadcn@latest add https://pastetaste.com/r/before-after-compare.json
   (it writes components/pastetaste/before-after-compare.tsx; install any npm packages it reports).
2. Import it: import { BeforeAfterCompare } from "@/components/pastetaste/before-after-compare" (check the file for the exact named export).
3. Put it where it fits on the page I name, keep the rest of the page untouched, and pass props for my colours instead of editing the installed file.
4. It does not depend on Tailwind; colours come from CSS variables (--pt-*) or props.
5. It supports prefers-reduced-motion with a still state; do not remove it.

Props (all optional unless the type has no default):
- before: { src: string; alt: string; label?: string; position?: string } — The picture shown left of the handle; label is the corner tag.
- after: { src: string; alt: string; label?: string; position?: string } — The picture underneath, revealed to the right of the handle.
- initial: number = 46 — Start position of the handle in percent.
- aspect: number = 1.95 — Width over height of the frame.
- caption: string — Caption under the frame.
- radius: number = 22 — Corner radius in px.
- min / max: number = 4 / 96 — Handle limits in percent.
- label: string = Compare before and after — Accessible name of the slider.
- className / style: string / CSSProperties — On the figure.

Live preview: https://pastetaste.com/c/before-after-compare
Then run the dev server, check it in the browser at desktop and mobile width, and tell me the page URL.

Props 9

PropTypeDefaultDescription
before{ src: string; alt: string; label?: string; position?: string }-The picture shown left of the handle; label is the corner tag.
after{ src: string; alt: string; label?: string; position?: string }-The picture underneath, revealed to the right of the handle.
initialnumber46Start position of the handle in percent.
aspectnumber1.95Width over height of the frame.
captionstring-Caption under the frame.
radiusnumber22Corner radius in px.
min / maxnumber4 / 96Handle limits in percent.
labelstringCompare before and afterAccessible name of the slider.
className / stylestring / CSSProperties-On the figure.
View all →