Basic Animations with animate Prop
You'll learn how to create smooth, declarative animations in Framer Motion by simply specifying target values.
The Core Idea
The animate prop on a motion component is your animation trigger. You pass it an object containing the CSS properties you want to animate and their target values—Framer Motion automatically animates from the current state to those targets. No keyframes, no CSS classes, just plain JavaScript objects.
Think of it like giving directions: instead of describing every step of a journey, you just say "go to 123 Main Street" and the GPS figures out the route. Similarly, you tell animate where to end up, and Framer Motion handles the journey.
Common Animation Properties
You can animate nearly any CSS property, but three are particularly powerful:
Opacity – Fade elements in or out:
<motion.div animate={{ opacity: 0.5 }}>
Fading element
</motion.div>
Position (x, y) – Move elements around (values in pixels):
<motion.div animate={{ x: 100, y: 50 }}>
Moving right and down
</motion.div>
Scale – Grow or shrink elements (1 = original size):
<motion.div animate={{ scale: 1.5 }}>
Growing element
</motion.div>
You can combine properties for richer effects:
<motion.div animate={{
opacity: 1,
x: 200,
scale: 1.2
}}>
Multi-property animation
</motion.div>
The animation starts automatically when the component mounts or when the animate values change.
Key Takeaway: The animate prop creates animations declaratively by specifying target values for opacity, position (x/y), scale, and other CSS properties—Framer Motion smoothly transitions from current to target states automatically.