Content
Framer Motion
Production-ready animation library for React. Motion (formerly Framer Motion) is the default choice for component-level animation: enter/exit transitions, layout shifts, gesture responses, spring physics, and scroll-linked effects. It integrates deeply with React's component model and handles the hard parts — interrupted animations, layout measurement, exit choreography — so you can focus on feel.
When to use
- Component mount/unmount transitions (modals, toasts, dropdowns, page transitions)
- Layout animations when elements reorder, resize, or move across containers
- Hover, tap, drag, and focus micro-interactions
- Shared element transitions across routes (with
layoutId) - Spring-based physics for interactive feel (sliders, toggles, cards)
- Scroll-linked opacity or parallax on individual elements
When NOT to use
- Scroll-driven pinning, scrubbing, or multi-section choreography — use GSAP + ScrollTrigger
- Complex multi-surface orchestration (DOM + Canvas + WebGL simultaneously) — use GSAP timelines
- Non-React projects — Motion is React-first; use GSAP or anime.js for vanilla JS
- CSS-only hover states where a 2-line transition suffices — do not over-engineer
- Performance-critical loops rendering thousands of animated items — profile first
Core concepts
motion components
Wrap any HTML or SVG element with animation superpowers:
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
/>