All Components
Animating Text with Framer Motion
Create
Eye-Catching
Experiences
With
Simple
UIs
Framer Motion is a powerful animation library for React that makes it easy to create smooth animations. In this guide, we'll explore two different ways to animate text:
- Animating words: The entire phrase is split into words, and each word is animated separately.
- Animating letters: The entire phrase is split into individual letters, and each letter is animated separately.
Let's begin by installing Framer Motion.
1. Animating Words
How it Works
- The headline string is split into words using
split(" "). - Each word is wrapped in a
<motion.p>component.
Initial State:
filter: "blur(10px)"applies a blur effect.opacity: 0makes the text invisible.y: 12moves the text downward.
Animate State:
filter: "blur(0)"removes the blur.opacity: 1makes the text fully visible.y: 0moves the text to its original position.
Transition:
duration: 0.5seconds for the animation.delay: 0.1 * indexadds a stagger effect, making each word appear in sequence.
2. Animating Letters
How it works
- The
headlinestring is split into individual letters usingsplit(""). - Each letter is wrapped in a
<motion.p>component. - Spaces are replaced with
"\u00A0"(non-breaking space) to maintain spacing.
Both animations provide engaging ways to animate text in React applications using Framer Motion. Depending on the use case, you can choose between animating words or letters. Animating words provides a smoother, more readable effect, while animating letters creates a dynamic, typewriter-like effect.
Happy Coding 👋
Want to Learn How to Build These Components Yourself?
We have step-by-step tutorials for every component to help you create stunning interfaces with ease.
Watch Tutorials on YouTube