Micro-interactions are the details that turn a good interface into an extraordinary experience. When a button clicks, a menu toggles, or a line loads, Framer Motion makes it simple to add natural, spring-based motions that feel tactile and satisfying.
Why Micro-Interactions Matter
Animations should not be distracting; they should assist user understanding. Well-designed animations can: - Guide a user's attention to status updates - Express hierarchy and relationships between components - Provide feedback to actions, such as button clicks or file loads
Designing Spring Animations in React
Framer Motion utilizes spring physics by default, which translates to realistic acceleration and deceleration curves, rather than mechanical linear curves.
Here’s a basic spring-animated card wrapper:
import { motion } from "framer-motion";
export const HoverCard = ({ children }) => (
<motion.div
whileHover={{ y: -8, scale: 1.02 }}
whileTap={{ scale: 0.98 }}
transition={{ type: "spring", stiffness: 300, damping: 20 }}
className="p-6 rounded-2xl glass"
>
{children}
</motion.div>
);
Advanced Tip: Staggered Animations
If you are rendering lists, staggering the animation of individual items makes the entrance feel organic and coordinated:
const containerVariants = {
hidden: { opacity: 0 },
visible: {
opacity: 1,
transition: {
staggerChildren: 0.1
}
}
};
const itemVariants = {
hidden: { opacity: 0, y: 20 },
visible: { opacity: 1, y: 0 }
};
export const AnimatedList = ({ items }) => (
<motion.ul variants={containerVariants} initial="hidden" animate="visible">
{items.map((item) => (
<motion.li key={item.id} variants={itemVariants}>
{item.text}
</motion.li>
))}
</motion.ul>
);
Key Takeaway
Framer Motion simplifies physics-based animation declarations. Use it key-by-key on interactive elements to build premium, immersive experiences that respond instantly to gestures.
