Building Stunning Animated UI with Framer Motion and Tailwind CSS in Next.js
Mudasir FayazIn today’s world of web design, animations are no longer optional — they’re what make a digital experience feel alive. With Framer Motion and Tailwind CSS, building those smooth, engaging animations in Next.jsbecomes effortless and elegant.
Why Combine Framer Motion with Tailwind?
Tailwind CSS handles the visual structure — spacing, colors, and layout. Framer Motion takes over the motion layer — orchestrating smooth transitions, hover effects, and scroll-based animations. Together, they create ahigh-performance animated UI without messy CSS keyframes or third-party plugins.
“Good animations don’t just move elements — they guide user attention and tell a story.”
Benefits of Using Framer Motion + Tailwind
- ✨ Build fluid UI transitions without writing custom CSS
- ⚙️ Animate components conditionally and on scroll
- 🎨 Maintain a clean, utility-first design system
- 🚀 Performant animations optimized for React & Next.js
Example: Fade-In Animation on Scroll
import { motion } from "framer-motion";
export default function FadeInSection() {
return (
<motion.div
initial={{ opacity: 0, y: 50 }}
whileInView={{ opacity: 1, y: 0 }}
transition={{ duration: 0.6, ease: "easeOut" }}
className="p-6 bg-white rounded-xl shadow-md"
>
<h2 className="text-xl font-semibold text-gray-800">
Animated Section
</h2>
<p className="text-gray-600 mt-2">
This content fades and slides in as it enters the viewport.
</p>
</motion.div>
);
}The above code creates a smooth fade-in and upward motion as the section enters view. Pair this with Tailwind’s utility classes to style the component beautifully — no external CSS required.
Wave Animation Effect with Delays
You can even create a wave-like animation pattern for a list of cards or elements by applying staggered transitions:
<motion.div
initial="hidden"
whileInView="visible"
variants={{
visible: {
transition: { staggerChildren: 0.15 },
},
}}
className="grid md:grid-cols-3 gap-6"
>
{cards.map((card, index) => (
<motion.div
key={index}
variants={{
hidden: { opacity: 0, y: 40 },
visible: { opacity: 1, y: 0 },
}}
className="bg-gray-50 rounded-xl p-6 shadow hover:shadow-lg transition"
>
{card.content}
</motion.div>
))}
</motion.div>This simple trick gives your UI a delightful cascading animation that feels natural and premium — a hallmark of good motion design.
Conclusion
Framer Motion and Tailwind CSS make a powerful duo for developers building with Next.js. Together, they help you craft UIs that are not only visually beautiful but also emotionally resonant. Start small — animate one section, a button, or a card grid — and watch how it transforms the feel of your app.