Course contentsShow
← React
Lesson 1967 of 2,39645. AnimationsFree lesson

The motion Component: Animating Any Element

Replace native HTML elements with motion.div, motion.button, etc. to enable animations.

The motion Component: Animating Any Element

What you'll learn: How Framer Motion's motion component replaces standard HTML elements to unlock declarative animations.

The Core Idea

In plain React, you animate elements by toggling classes or inline styles that trigger CSS transitions. Framer Motion takes a different approach: it provides enhanced versions of every HTML element through the motion object. Instead of <div>, you use <motion.div>. Instead of <button>, you use <motion.button>. These special components accept all the props their native counterparts do, but also understand animation instructions like animate, initial, and whileHover.

Think of motion components as supercharged HTML elements with animation superpowers built in. You're still rendering a div or button to the DOM — Framer Motion just wraps it with extra functionality.

How It Works

import { motion } from 'framer-motion';

function AnimatedBox() {
  return (
    <motion.div
      initial={{ opacity: 0 }}
      animate={{ opacity: 1 }}
      className="box"
    >
      I fade in automatically!
    </motion.div>
  );
}

Here, motion.div replaces a regular <div>. The initial prop sets the starting state (invisible), and animate defines where it should go (fully visible). Framer Motion handles the transition automatically — no CSS classes, no onTransitionEnd callbacks.

You can use motion.button, motion.span, motion.ul, or any other HTML element. Even SVG elements like motion.path or motion.circle work identically.

When You Use It

Every time you want an element to animate with Framer Motion, replace the HTML tag with its motion. equivalent. That's the foundation for everything else Framer Motion offers.

Key Takeaway: The motion component transforms any HTML element into an animatable version by simply prefixing it with motion. — it's your entry point to declarative animations without manual CSS transitions.