Scroll Scramble Section
Scroll-driven text animation with GSAP Flip and scramble effects. Elements morph smoothly while text dynamically reveals on scroll — ideal for cinematic, immersive landing sections.
Page TransitionReactGSAPScrollTrigger
CSSTailwind
Manual
Create a file and paste the following code into it.
src/components/ui/scroll-text-motion.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
import { useRef } from "react";
import {
useScrollTextMotion,
type ScrollTextGroup,
} from "@/hooks/use-scroll-text-motion";
interface ScrollTextMotionProps {
groups: ScrollTextGroup[];
logo?: string;
className?: string;
}
export type { ScrollTextEl, ScrollTextGroup } from "@/hooks/use-scroll-text-motion";
export function ScrollTextMotion({
groups,
logo,
className = "",
}: ScrollTextMotionProps) {
const contentRef = useRef<HTMLDivElement>(null);
const logoRef = useRef<HTMLSpanElement>(null);
const progressFillRef = useRef<HTMLDivElement>(null);
useScrollTextMotion(contentRef, logoRef, progressFillRef, groups, logo);
return (
<div
className={`scroll-text-motion min-h-dvh bg-black text-white ${className}`}
>
{/* Scroll progress indicator — scaleY driven by GSAP ScrollTrigger onUpdate.
Track: right edge, 1px wide, GPU-composited transform (no reflow per frame). */}
<div
aria-hidden="true"
style={{
position: "fixed",
top: 0,
right: "10px",
width: "1px",
height: "100vh",
background: "rgba(0,255,65,0.08)",
zIndex: 200,
pointerEvents: "none",
}}
>
<div
ref={progressFillRef}
style={{
width: "100%",
height: "100%",
background: "rgba(0,255,65,0.6)",
transformOrigin: "top center",
transform: "scaleY(0)",
}}
/>
</div>
{logo && (
<div className="scroll-text-fixed fixed inset-0 grid place-items-center pointer-events-none z-0">
<div className="scroll-text-logo text-[clamp(2rem,10vw,4rem)] font-black">
<span ref={logoRef}>{logo}</span>
</div>
</div>
)}
<div
className="scroll-text-content pt-[100vh] pb-[25vh] px-6 relative z-10"
ref={contentRef}
>
{groups.map((group, gi) => (
<div key={gi} className="scroll-text-group flex flex-col mb-[10vh]">
{group.items.map((item, ii) => (
<div
key={ii}
className={`scroll-text-el el whitespace-nowrap uppercase ${
item.pos
} ${item.xl ? "el--xl" : ""} ${
item.typingIndicator ? "typing-indicator" : ""
}`}
data-alt-pos={item.altPos}
data-flip-ease={item.flipEase ?? "expo.inOut"}
data-scramble-duration={String(item.scrambleDuration ?? 1)}
>
<span className="scroll-text-inner">{item.text}</span>
</div>
))}
</div>
))}
</div>
<style>{`
/* ── Google Fonts: Azeret Mono (body) + Instrument Serif (XL) + Unbounded (logo) ── */
@import url('https://fonts.googleapis.com/css2?family=Azeret+Mono:wght@400;500;600;700&family=Instrument+Serif:ital@1&family=Unbounded:wght@700;800;900&display=swap');
/* ── Base ── */
.scroll-text-motion {
font-family: "Azeret Mono", "IBM Plex Mono", "Courier New", monospace;
text-transform: uppercase;
letter-spacing: 0.08em;
color: #e8e4de;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
overflow-x: hidden;
}
/* ── Grain texture overlay ── */
.scroll-text-motion::before {
content: "";
position: fixed;
inset: 0;
z-index: 100;
pointer-events: none;
opacity: 0.05;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
background-size: 200px 200px;
background-repeat: repeat;
}
/* ── Scanline overlay (layered with grain for CRT depth) ── */
.scroll-text-motion::after {
content: "";
position: fixed;
inset: 0;
z-index: 101;
pointer-events: none;
opacity: 0.03;
background: repeating-linear-gradient(
0deg,
transparent,
transparent 2px,
rgba(0, 255, 65, 0.06) 2px,
rgba(0, 255, 65, 0.06) 4px
);
}
/* ── Text elements ── */
.scroll-text-el.el { white-space: nowrap; filter: blur(0); opacity: 0.55; }
/* ── XL letters: Instrument Serif Italic + chromatic aberration ── */
.scroll-text-el.el--xl {
font-size: clamp(2rem, 22vw, 16rem);
opacity: 1;
font-family: "Instrument Serif", Georgia, "Times New Roman", serif;
font-style: italic;
font-weight: 400;
color: #f0ebe3;
text-shadow:
-3px 0 rgba(255, 40, 80, 0.35),
3px 0 rgba(0, 255, 70, 0.4),
0 0 120px rgba(0, 255, 65, 0.08),
0 0 300px rgba(0, 255, 65, 0.03);
}
/* ── Logo ── */
.scroll-text-logo {
font-family: "Unbounded", "Space Grotesk", "Arial Black", sans-serif;
letter-spacing: 0.02em;
}
/* ══ Position system ══
Naming: pos-{horizontal}-{descriptor}
All classes MUST start with "pos-" (JS: c.startsWith("pos-"))
Horizontal slots:
edge-left → no margin (flush left)
quarter → 25vw
far-right → ~70vw (clamped: never clips text on mobile)
flush-right → margin-left: auto
Vertical/effect modifiers:
-low → vertical drop + full opacity
-haze → vertical drop + blur
-deep → large vertical drop
min() on far-right: min(70vw, calc(100% - 12ch))
12ch ≈ 12 character widths in the monospace font
ensures last word always has enough room before container edge
*/
.scroll-text-el.pos-edge-left {}
.scroll-text-el.pos-quarter { margin-left: 25vw; }
.scroll-text-el.pos-far-right { margin-left: min(70vw, calc(100% - 12ch)); }
.scroll-text-el.pos-flush-right { margin-left: auto; }
.scroll-text-el.pos-edge-low { margin-top: clamp(80px, 15vh, 200px); opacity: 1; }
.scroll-text-el.pos-right-low { margin-left: auto; margin-top: clamp(80px, 15vh, 200px); opacity: 1; }
.scroll-text-el.pos-edge-haze { margin-top: clamp(80px, 15vh, 200px); opacity: 1; filter: blur(1.2px); }
.scroll-text-el.pos-quarter-haze { margin-left: 25vw; margin-top: clamp(20px, 5vh, 50px); opacity: 1; filter: blur(2px); }
.scroll-text-el.pos-quarter-deep { margin-left: 25vw; margin-top: clamp(100px, 20vh, 250px); }
.scroll-text-el.pos-far-deep { margin-left: min(70vw, calc(100% - 12ch)); margin-top: 40vh; }
/* ── Mobile breakpoints ──
At ≤640px, far-right collapses to avoid text clipping off-screen.
Quarter positions tighten slightly for narrower columns. */
@media (max-width: 640px) {
.scroll-text-el.pos-far-right { margin-left: min(50vw, calc(100% - 8ch)); }
.scroll-text-el.pos-far-deep { margin-left: min(50vw, calc(100% - 8ch)); }
.scroll-text-el.pos-quarter { margin-left: 18vw; }
.scroll-text-el.pos-quarter-haze { margin-left: 18vw; }
.scroll-text-el.pos-quarter-deep { margin-left: 18vw; }
}
/* ── Typing cursor ── */
@keyframes blink-cursor { from, to { opacity: 1; } 50% { opacity: 0; } }
.scroll-text-el.typing-indicator { display: inline-block; animation: blink-cursor 0.7s linear infinite; }
`}</style>
</div>
);
}Update the import paths to match your project setup.