Text
Before and After Text
The old way is crossed out and the new way takes its place.
"use client";
import { useRef } from "react";
import gsap from "gsap";
import { useGSAP } from "@gsap/react";
gsap.registerPlugin(useGSAP);
export type BeforeAfterRow = { before: string; after: string };
export type BeforeAfterTextProps = {
/** Heading above the rows. */
title?: string;
/** Each row: the old way and the new way. */
rows?: BeforeAfterRow[];
/** Color of the new way. */
accent?: string;
/** Replay forever with a pause between runs. */
loop?: boolean;
className?: string;
};
export default function BeforeAfterText({
title = "Before and after",
rows = [
{ before: "Tracking leads in spreadsheets", after: "Every lead in one pipeline" },
{ before: "Forgotten follow-ups", after: "Reminders sent on time" },
{ before: "Guessing the calendar", after: "Live availability" },
],
accent = "#1f5bff",
loop = true,
className = "",
}: BeforeAfterTextProps) {
const root = useRef<HTMLDivElement>(null);
useGSAP(
() => {
const q = gsap.utils.selector(root);
const tl = gsap.timeline({ repeat: loop ? -1 : 0, repeatDelay: 1.4 });
tl.set(q("[data-strike]"), { scaleX: 0 })
.set(q("[data-new]"), { autoAlpha: 0, y: 18, filter: "blur(8px)" })
.fromTo(q("[data-title]"), { autoAlpha: 0, filter: "blur(4px)" }, { autoAlpha: 1, filter: "blur(0px)", duration: 0.5, ease: "power2.out" }, 0)
.fromTo(
q("[data-old]"),
{ autoAlpha: 0, x: -14, y: 0, filter: "blur(6px)" },
{ autoAlpha: 1, x: 0, filter: "blur(0px)", duration: 0.6, ease: "expo.out", stagger: 0.12 },
0.1,
);
q("[data-row]").forEach((row: Element, i: number) => {
const at = 1.2 + i * 0.9;
tl.to(row.querySelector("[data-strike]"), { scaleX: 1, duration: 0.45, ease: "expo.inOut" }, at)
.to(row.querySelector("[data-old]"), { autoAlpha: 0, y: -16, filter: "blur(5px)", duration: 0.4, ease: "power2.in" }, at + 0.45)
.to(row.querySelector("[data-new]"), { autoAlpha: 1, y: 0, filter: "blur(0px)", duration: 0.7, ease: "expo.out" }, at + 0.6);
});
tl.to({}, { duration: 1.8 });
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) tl.progress(1).pause();
},
{ scope: root, dependencies: [loop, rows.map((r) => r.before + r.after).join("|")] },
);
return (
<div ref={root} className={`w-full max-w-xl ${className}`}>
<p data-title className="mb-4 text-xs font-semibold tracking-[0.14em] text-current/60 uppercase">
{title}
</p>
<div className="flex flex-col gap-2.5">
{rows.map((row, i) => (
<div key={i} data-row className="relative h-11">
<span data-old className="absolute top-0 left-0 text-base leading-[44px] whitespace-nowrap text-current/60">
{row.before}
<i
data-strike
aria-hidden="true"
className="absolute top-1/2 -inset-x-0.5 h-0.5 origin-left bg-red-600/70"
/>
</span>
<span
data-new
className="absolute top-0 left-0 flex items-center text-base leading-[44px] font-semibold whitespace-nowrap"
style={{ color: accent }}
>
<b className="mr-2.5 inline-block h-2 w-2 rounded-full" style={{ backgroundColor: accent }} />
{row.after}
</span>
</div>
))}
</div>
</div>
);
}
Paste this into Claude Code inside your project. It installs the skills your agent needs, asks for your texts and colors, and recreates this animation in your stack.
SkillsGSAP skillsHyperFrames · optional, for video
Claude Code
Recreate the "Before and After Text" animated component from Motionshelf (https://motionshelf-pi.vercel.app) in my current project, adapted to my brand. Answer me in the language I write to you in. Work in this order: 1. Tools: Check whether the official GSAP skills are installed (gsap-core, gsap-timeline, gsap-react). If they are not, ask me and then run `npx skills add https://github.com/greensock/gsap-skills` (choose Claude Code). If they do not show up in this session yet, read the SKILL.md files the installer created for gsap-timeline and gsap-react before writing code. 2. Project: Look at my project: framework (Next.js, Vite, plain HTML…), TypeScript or JavaScript, Tailwind or plain CSS. Build it as one component that fits this stack. In React use gsap and @gsap/react; in plain HTML use GSAP from npm or a CDN. 3. Ask me before coding: Ask me these in a single message, showing the example values as defaults: - the heading - each row: the old way and the new way - the accent color of the new way - the language of the texts 4. The animation What it looks like: A small heading and three rows. Each row shows an old way of doing something; it gets crossed out and the new way appears in its place, with a colored dot. Step by step: - The heading fades in (0.5 s) and the old texts slide in from the left with a slight blur, one after another (stagger 0.12 s). - From 1.2 s, row by row every 0.9 s: a strike line grows across the old text (scaleX, 0.45 s), the old text leaves upward with blur, and the new text rises in (0.7 s, expo.out). - Everything holds 1.8 s and the loop restarts. Rules: - Use one GSAP timeline that loops forever with a short pause between runs (repeat: -1). If the step by step gives the pause, use that value; otherwise repeatDelay about 1.4 s. - Set every starting state with set() at the start of the timeline, never with from(): on the second loop from() starts from the wrong place. - Elements that appear later and would push the layout (new chat bubbles, new rows) stay display:none until their turn; elements that already have their place in the layout (a subtitle, a button) start hidden with autoAlpha 0, so nothing jumps. - If there is a cursor or pointer, it aims at the measured center of its target (getBoundingClientRect), never at fixed pixel coordinates; if the component is scaled, divide by the scale. - Blur only in the middle of a movement and always end at blur(0). - With prefers-reduced-motion, jump to the final frame and stop (tl.progress(1).pause()). - In React, use useGSAP from @gsap/react with a scope ref, so the timeline is cleaned up on unmount. - All example content stays generic (no real brands, logos or people). - Old and new texts share the same spot in each row (stacked), so nothing jumps when they swap. 5. Check: Run it and watch the first and the third loop (they must look the same). Check it at 390 px wide with no sideways scroll, with reduced motion turned on, and with a clean console. Tell me what you checked. 6. Video (optional): If I also want this as an MP4 (ads, stories, WhatsApp status), install the HyperFrames plugin with `claude plugin marketplace add heygen-com/hyperframes` and `claude plugin install hyperframes@hyperframes`, then use /hyperframes:hyperframes to render the same animation in 9:16, 1:1 or 16:9. Rendering needs FFmpeg installed, or render with --docker (downloads about 3.3 GB the first time). Ask me before installing. Shortcut: If I only want the ready-made component instead, it installs with `npx shadcn@latest add https://motionshelf-pi.vercel.app/r/before-after-text.json`.
Other agentsUsing Cursor, Codex, Gemini CLI or another agent? This version tells it to find its own way to load the same skills before it starts.
Other agents
Recreate the "Before and After Text" animated component from Motionshelf (https://motionshelf-pi.vercel.app) in my current project, adapted to my brand. Answer me in the language I write to you in. Work in this order: 1. Tools: These instructions were written for Claude Code, which uses "skills" (folders with a SKILL.md that teach it a technique). First find out how you load skills, rules or instructions, and get the same knowledge: (a) if your agent is supported by the skills installer, ask me and run `npx skills add https://github.com/greensock/gsap-skills --agent <your-agent>` (for example codex, opencode, antigravity); (b) otherwise copy the skill folders from https://github.com/greensock/gsap-skills into your skills or rules directory (in Cursor: Settings → Rules → Remote Rule (GitHub) → greensock/gsap-skills); (c) if you cannot load skills at all, open the SKILL.md files in https://github.com/greensock/gsap-skills and read them as instructions before coding. Tell me which path you used. 2. Project: Look at my project: framework (Next.js, Vite, plain HTML…), TypeScript or JavaScript, Tailwind or plain CSS. Build it as one component that fits this stack. In React use gsap and @gsap/react; in plain HTML use GSAP from npm or a CDN. 3. Ask me before coding: Ask me these in a single message, showing the example values as defaults: - the heading - each row: the old way and the new way - the accent color of the new way - the language of the texts 4. The animation What it looks like: A small heading and three rows. Each row shows an old way of doing something; it gets crossed out and the new way appears in its place, with a colored dot. Step by step: - The heading fades in (0.5 s) and the old texts slide in from the left with a slight blur, one after another (stagger 0.12 s). - From 1.2 s, row by row every 0.9 s: a strike line grows across the old text (scaleX, 0.45 s), the old text leaves upward with blur, and the new text rises in (0.7 s, expo.out). - Everything holds 1.8 s and the loop restarts. Rules: - Use one GSAP timeline that loops forever with a short pause between runs (repeat: -1). If the step by step gives the pause, use that value; otherwise repeatDelay about 1.4 s. - Set every starting state with set() at the start of the timeline, never with from(): on the second loop from() starts from the wrong place. - Elements that appear later and would push the layout (new chat bubbles, new rows) stay display:none until their turn; elements that already have their place in the layout (a subtitle, a button) start hidden with autoAlpha 0, so nothing jumps. - If there is a cursor or pointer, it aims at the measured center of its target (getBoundingClientRect), never at fixed pixel coordinates; if the component is scaled, divide by the scale. - Blur only in the middle of a movement and always end at blur(0). - With prefers-reduced-motion, jump to the final frame and stop (tl.progress(1).pause()). - In React, use useGSAP from @gsap/react with a scope ref, so the timeline is cleaned up on unmount. - All example content stays generic (no real brands, logos or people). - Old and new texts share the same spot in each row (stacked), so nothing jumps when they swap. 5. Check: Run it and watch the first and the third loop (they must look the same). Check it at 390 px wide with no sideways scroll, with reduced motion turned on, and with a clean console. Tell me what you checked. 6. Video (optional): If I also want this as an MP4 (ads, stories, WhatsApp status), install the HyperFrames skills with `npx skills add heygen-com/hyperframes` (choose your agent) and render the same animation in 9:16, 1:1 or 16:9. Rendering needs FFmpeg installed, or render with --docker (downloads about 3.3 GB the first time). Ask me before installing. Shortcut: If I only want the ready-made component instead, it installs with `npx shadcn@latest add https://motionshelf-pi.vercel.app/r/before-after-text.json`.
Install
npx shadcn@latest add https://motionshelf-pi.vercel.app/r/before-after-text.jsonCopies the file into your project. Requires React 19, Tailwind CSS v4 and GSAP (installed as a dependency).
Props
| Name | Type | Default | Description |
|---|---|---|---|
| title | string | "Before and after" | Heading above the rows. |
| rows | { before: string; after: string }[] | three example rows | Each row: the old way and the new way. |
| accent | string | "#1f5bff" | Color of the new way. |
| loop | boolean | true | Replay forever with a pause between runs. |
| className | string | "" | Extra classes for the outer element. |
Dependencies
- gsap
- @gsap/react