Before/After Slider CTA
A call-to-action section built around a draggable before/after image comparison, with a persistent call-to-action button underneath. Supports both mouse and touch input via a native range input.
Docs
Installation
A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its button dependencies and any missing npm packages, and installs them straight into your project.
npx shadcn add https://staaarter.com/r/before-after-slider-cta.jsonPrefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/cta/cta46.tsx instead.
Usage
The file also exports cta46Demo, the exact props behind the preview above. Spread it to get a working section in one line, then replace it with your own data.
import { Cta46, cta46Demo } from "@/components/blocks/cta/cta46"; export default function Page() { return <Cta46 {...cta46Demo} />; }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| heading | string | "See the difference for yourself" | Main heading. |
| description | string | "Drag the slider to compare before and after..." | Supporting copy under the heading. |
| beforeImage | { src: string; alt: string } | none | The bottom, "before" image layer. Required. |
| afterImage | { src: string; alt: string } | none | The top, "after" image layer, revealed by the slider. Required. |
| beforeLabel | string | "Before" | Label chip over the before side. |
| afterLabel | string | "After" | Label chip over the after side. |
| primaryLabel | string | "Get your before/after" | Call-to-action button label. |
| primaryHref | string | "#" | Link target for the call-to-action button. |
| className | string | none | Extra classes for the outer section element. |
Behavior notes
- The comparison slider is a real, fully accessible native <input type="range"> wired to a useState<number>, with a proper <Label htmlFor> (visually hidden, read by screen readers). Its value drives a clip-path: inset(...) on the "after" image layer stacked on top of the "before" image, so dragging the range reveals more or less of the after image.
- Using a native range input (rather than hand-rolled pointer-event drag logic) gives real mouse AND touch support for free, plus a genuinely accessible, keyboard-operable control.
- The call-to-action button is decorative: it renders as a real Next.js Link via the button's render prop, but defaults to "#" and doesn't perform a real navigation of its own.
More CTA Blocks
View all →centered-newsletter-cta
Centered Newsletter CTA
Minimal centered call-to-action with heading, description, and action buttons.
split-layout-newsletter-cta
Split Layout Newsletter CTA
Two-column call-to-action with a decorative image on one side and a feature list plus subscribe form on the other.
newsletter-social-proof-cta
Newsletter CTA with Social Proof
Newsletter call-to-action with an avatar stack, subscriber count, and a testimonial quote.
banner-cta
Banner CTA
Horizontal banner call-to-action with heading and action buttons side by side.
stats-cta
Stats CTA
Call-to-action section with impressive statistics and trust indicators above action buttons.
multi-card-cta
Multi-Card CTA
Three action cards side by side, each offering a different path to conversion.