Back to results for “Performance”
React › Animation in React (Framer Motion & React Spring)

What is Framer Motion and how does it make animating React components easier?

Beginner

Answer

Framer Motion is a popular animation library for React. Instead of writing complex CSS animations by hand, you use its motion components and simply describe the starting state, the ending state, and how long the change should take. Framer Motion handles all the smooth transition work for you.
import { motion } from 'framer-motion';

function FadeInBox() {
  return (
    <motion.div
      initial={{ opacity: 0 }}
      animate={{ opacity: 1 }}
      transition={{ duration: 0.5 }}
    >
      Hello there
    </motion.div>
  );
}
Real-world example A landing page uses Framer Motion to fade in each section as the user scrolls down, making the page feel more polished without writing any custom CSS keyframes.

Common follow-ups: How do you trigger an animation only when an element scrolls into view?;What is the difference between the animate prop and the whileHover prop?