DEV Community

Manu Kumar Pal
Manu Kumar Pal

Posted on

Framer Motion + Tailwind: The 2025 Animation Stack

Animation in frontend has gone from “nice-to-have” to core UX.
In 2025, users expect smooth, context-aware transitions — not just buttons that move.

Framer Motion and Tailwind CSS — two tools that, when combined, give you an elegant, scalable animation workflow without the usual headache of CSS keyframes or timeline-based libraries.

💡 What Are These Tools?

🧩 Tailwind CSS

✅ Utility-first CSS framework
✅ You use short class names like p-4, bg-blue-500, rounded-xl
✅ No need to leave your HTML or JSX file

Example:

<div class="p-4 bg-blue-500 text-white rounded-xl"> Hello Tailwind! </div> 
Enter fullscreen mode Exit fullscreen mode

🎬 Framer Motion

✅ A React animation library
✅ Lets you animate anything easily
✅ Works great with Next.js, React, or Remix

Example:

import { motion } from "framer-motion"; <motion.div animate={{ x: 100 }}>I move!</motion.div> 
Enter fullscreen mode Exit fullscreen mode

🚀 Why Use Both Together?

✅ Tailwind handles style
✅ Framer Motion handles movement
✅ You get clean design + smooth animation ✨

🧱 Example 1: Simple Hover Animation

Let’s make a button that moves a little when hovered.

import { motion } from "framer-motion"; export default function Button() { return ( <motion.button whileHover={{ scale: 1.1 }} whileTap={{ scale: 0.95 }} className="px-4 py-2 bg-indigo-600 text-white rounded-lg font-medium" > Hover Me 🚀 </motion.button> ); } 
Enter fullscreen mode Exit fullscreen mode

🧠 What’s happening:

✅ whileHover → scales up the button slightly
✅ whileTap → shrinks it when clicked
✅ Tailwind adds styling and shape
✅ Result → A smooth, responsive button that feels alive ✨

🎛️ Example 2: Fade-In Animation

Let’s make a card that fades in when it appears.

import { motion } from "framer-motion"; export default function Card() { return ( <motion.div initial={{ opacity: 0, y: 30 }} animate={{ opacity: 1, y: 0 }} transition={{ duration: 0.6 }} className="p-6 bg-white rounded-2xl shadow-lg" > <h2 className="text-xl font-semibold">Animated Card</h2> <p className="text-gray-600 mt-2"> This card fades in smoothly when loaded. </p> </motion.div> ); } 
Enter fullscreen mode Exit fullscreen mode

🧠 Explanation:

✅ initial → where animation starts
✅ animate → where it ends
✅ transition → how fast or smooth
✅ Tailwind gives it padding, color, and shadow
✅ Simple, clear, and works perfectly across devices.

🧭 Bonus Tip: Animate Page Transitions

If you use Next.js, wrap your pages with AnimatePresence:

import { AnimatePresence, motion } from "framer-motion"; <AnimatePresence mode="wait"> <motion.div key={router.asPath} initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} transition={{ duration: 0.3 }} > {children} </motion.div> </AnimatePresence> 
Enter fullscreen mode Exit fullscreen mode

🧠 Final Thoughts

In 2025, good animations = better UX.
Framer Motion and Tailwind make it possible to add motion without complexity.

They’re:

✅ Easy to learn 🧑‍💻
✅ Clean to use 💅
✅ Fun to experiment with 🚀

If you’re building modern UIs — this combo should be your go-to animation stack.

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.