---
name: framer-motion
description: Comprehensive Framer Motion animation library for React. Covers motion components, variants, gestures, page transitions, and scroll animations. Use when adding animations to React/Next.js applications.
---
# Framer Motion Skill
Production-ready animations for React applications.
## Quick Start
### Installation
```bash
npm install framer-motion
# or
pnpm add framer-motion
```
### Basic Usage
```tsx
import { motion } from "framer-motion";
// Simple animation
Content
```
## Core Concepts
| Concept | Guide |
|---------|-------|
| **Motion Component** | [reference/motion-component.md](reference/motion-component.md) |
| **Variants** | [reference/variants.md](reference/variants.md) |
| **Gestures** | [reference/gestures.md](reference/gestures.md) |
| **Hooks** | [reference/hooks.md](reference/hooks.md) |
## Examples
| Pattern | Guide |
|---------|-------|
| **Page Transitions** | [examples/page-transitions.md](examples/page-transitions.md) |
| **List Animations** | [examples/list-animations.md](examples/list-animations.md) |
| **Scroll Animations** | [examples/scroll-animations.md](examples/scroll-animations.md) |
| **Micro-interactions** | [examples/micro-interactions.md](examples/micro-interactions.md) |
## Templates
| Template | Purpose |
|----------|---------|
| [templates/page-transition.tsx](templates/page-transition.tsx) | Page transition wrapper |
| [templates/animated-list.tsx](templates/animated-list.tsx) | Animated list component |
## Quick Reference
### Basic Animation
```tsx
Content
```
### Hover & Tap
```tsx
Click me
```
### Variants
```tsx
const container = {
hidden: { opacity: 0 },
show: {
opacity: 1,
transition: { staggerChildren: 0.1 }
}
};
const item = {
hidden: { opacity: 0, y: 20 },
show: { opacity: 1, y: 0 }
};
{items.map(i => (
{i}
))}
```
### AnimatePresence (Exit Animations)
```tsx
import { AnimatePresence, motion } from "framer-motion";
{isVisible && (
Modal content
)}
```
### Scroll Trigger
```tsx
Animates when scrolled into view
```
### Drag
```tsx
Drag me
```
### Layout Animation
```tsx
Content that animates when layout changes
```
## Transition Types
```tsx
// Tween (default)
transition={{ duration: 0.3, ease: "easeOut" }}
// Spring
transition={{ type: "spring", stiffness: 300, damping: 20 }}
// Spring presets
transition={{ type: "spring", bounce: 0.25 }}
// Inertia (for drag)
transition={{ type: "inertia", velocity: 50 }}
```
## Easing Functions
```tsx
// Built-in easings
ease: "linear"
ease: "easeIn"
ease: "easeOut"
ease: "easeInOut"
ease: "circIn"
ease: "circOut"
ease: "circInOut"
ease: "backIn"
ease: "backOut"
ease: "backInOut"
// Custom cubic-bezier
ease: [0.17, 0.67, 0.83, 0.67]
```
## Reduced Motion
Always respect user preferences:
```tsx
import { motion, useReducedMotion } from "framer-motion";
function Component() {
const prefersReducedMotion = useReducedMotion();
return (
Respects motion preferences
);
}
// Or use media query
const variants = {
initial: { opacity: 0 },
animate: { opacity: 1 },
};
```
## Common Patterns
### Fade In Up
```tsx
const fadeInUp = {
initial: { opacity: 0, y: 20 },
animate: { opacity: 1, y: 0 },
transition: { duration: 0.4 }
};
Content
```
### Staggered List
```tsx
const container = {
hidden: { opacity: 0 },
show: {
opacity: 1,
transition: { staggerChildren: 0.1, delayChildren: 0.2 }
}
};
const item = {
hidden: { opacity: 0, x: -20 },
show: { opacity: 1, x: 0 }
};
```
### Modal
```tsx
{isOpen && (
<>
{/* Backdrop */}
{/* Modal */}
Modal content
>
)}
```
### Accordion
```tsx
Accordion content
```
## Best Practices
1. **Use variants**: Cleaner code, easier orchestration
2. **Respect reduced motion**: Always check `useReducedMotion`
3. **Use `layout` sparingly**: Can be expensive, use only when needed
4. **Exit animations**: Wrap with `AnimatePresence`
5. **Spring for interactions**: More natural feel for hover/tap
6. **Tween for page transitions**: More predictable timing
7. **GPU-accelerated properties**: Prefer `opacity`, `scale`, `x`, `y` over `width`, `height`