GSAP SplitText Plugin (Text Animation Made Easy)
- SplitText lets you break text into characters, words, or lines and animate them easily using GSAP.
Introduction
SplitText is a GSAP plugin that allows you to split text into characters, words, or lines so you can animate them individually.
It is commonly used for:
-
Hero section text animations
-
Typography-based websites
-
Headline reveals
-
Creative UI transitions
SplitText is a premium plugin provided by GreenSock GSAP.
-
Basic Concept
Normally, text is a single element and cannot be animated letter by letter.
👉 SplitText solves this by:
-
Wrapping each character/word/line in a
<span> -
Giving you full control over each part
-
Letting GSAP animate them individually
Think of it as breaking text into animation-ready pieces.
-
nstallation / Setup
<script src="https://unpkg.com/gsap@3/dist/gsap.min.js"></script>
<script src="https://unpkg.com/gsap@3/dist/SplitText.min.js"></script>
gsap.registerPlugin(SplitText);
Basic Syntax
const split = new SplitText(".title", { type: "chars" });
gsap.from(split.chars, {
y: 50,
opacity: 0,
stagger: 0.05
});
Parameters / Options
Option Meaning Example typeHow to split text "chars, words, lines"charsArray of characters split.chars wordsArray of words split.words linesArray of lines split.lines revert()Restore original text split.revert()
Character Animation
const split = new SplitText("h1", { type: "chars" });
gsap.from(split.chars, {
y: 80,
opacity: 0,
stagger: 0.04,
ease: "power4.out"
});
Word-by-Word Animation
const split = new SplitText(".text", { type: "words" });
gsap.from(split.words, {
opacity: 0,
y: 20,
stagger: 0.1
});
Line Reveal Animation
const split = new SplitText(".headline", { type: "lines" });
gsap.from(split.lines, {
yPercent: 100,
stagger: 0.2
});
Scroll-Based Text Animation
const split = new SplitText(".title", { type: "chars" });
gsap.from(split.chars, {
opacity: 0,
y: 40,
stagger: 0.05,
scrollTrigger: {
trigger: ".title",
start: "top 80%"
}
});
Best Practices
-
Use chars for short headlines
-
Use words/lines for paragraphs
-
Always revert before page destroy
-
Combine with timelines for smooth reveals
-
Comparison
Method Use Case SplitText Advanced text animation CSS animation Limited control Letter-spacing tricks Hacky Lottie Pre-rendered
Quick Summary
-
SplitText breaks text into pieces
-
Animate characters, words, or lines
-
Perfect for typography animations
-
Premium GSAP plugin
-
Works with ScrollTrigger & timelines
-