The motion Component
You'll learn: How Framer Motion's motion component transforms ordinary HTML and SVG elements into animatable powerhouses.
What Is the motion Component?
The motion component is Framer Motion's core building block—it's essentially a wrapper that supercharges any HTML or SVG element with animation capabilities. Think of it as giving your static elements a "motion upgrade" that unlocks all of Framer Motion's animation features.
Instead of writing <div>, you write <motion.div>. Instead of <svg>, you use <motion.svg>. The element looks and behaves exactly the same, but now it understands Framer Motion's animation props.
How It Works
Framer Motion provides a motion object with properties for every standard HTML and SVG element. When you render a motion component, it creates the underlying element but enhances it to respond to animation props like animate, initial, transition, and more.
Analogy: Imagine regular HTML elements are like bicycles—functional and useful. The motion component is like attaching an electric motor to that bicycle. It's still a bicycle, still does everything a bicycle does, but now it has extra capabilities built in.
import { motion } from 'framer-motion';
function AnimatedBox() {
return (
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
transition={{ duration: 1 }}
>
I'm now animatable!
</motion.div>
);
}
You can use motion with any valid HTML tag (motion.button, motion.span, motion.header) or SVG element (motion.circle, motion.path). The motion component passes through all standard attributes and props—it's a drop-in replacement.
Key Takeaway: The motion component is Framer Motion's wrapper that transforms any HTML or SVG element into an animation-ready component, giving you access to declarative animation props while preserving all native element functionality.