framer-motion
18
总安装量
18
周安装量
#19190
全站排名
安装命令
npx skills add https://github.com/huynhsang2005/blog-tanstack --skill framer-motion
Agent 安装分布
claude-code
11
cursor
10
codex
10
opencode
8
gemini-cli
8
antigravity
7
Skill 文档
Framer Motion Skill
When to use
- Adding page transitions or route animations.
- Creating component enter/exit animations.
- Building gesture interactions (drag, hover, tap).
- Animating lists with stagger effects.
Guardrails
- Keep animations under 300ms for snappiness.
- Always respect
prefers-reduced-motion. - Use
variantsfor complex, coordinated animations (not inline). - Animate transform/opacity only (avoid layout thrash).
Workflow checklist
- Identify what should animate and when (mount, route change, user interaction).
- Define
variantsfor multi-state animations (initial, animate, exit). - Use
motioncomponents (motion.div,motion.span) for animated elements. - Coordinate children with
staggerChildrenin parent variants. - Test with reduced motion to ensure accessible fallbacks.
Common patterns
Page transitions
import { motion } from 'framer-motion'
export function PageTransition({ children }: { children: React.ReactNode }) {
return (
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: -20 }}
transition={{ duration: 0.3 }}
>
{children}
</motion.div>
)
}
Stagger children
const container = {
hidden: { opacity: 0 },
show: {
opacity: 1,
transition: {
staggerChildren: 0.1
}
}
}
const item = {
hidden: { opacity: 0, y: 20 },
show: { opacity: 1, y: 0 }
}
<motion.div variants={container} initial="hidden" animate="show">
{items.map(item => (
<motion.div key={item.id} variants={item}>
{item.content}
</motion.div>
))}
</motion.div>
Best practices
- â
Use
variantsfor readability and reusability - â Keep duration under 300ms for UI responsiveness
- â Animate transform/opacity (GPU-accelerated)
- â
Add
layoutprop for automatic layout animations - â Don’t animate width/height directly (causes layout thrash)
- â Don’t nest many
motioncomponents (performance)
References
- Library patterns: docs/dev-1/docs/16-library-patterns.md#framer-motion
- Design system: docs/dev-1/docs/13-unified-design-system.md (animation tokens)
Tooling
- Use Context7 or web search for framer-motion API details when needed.