About framer-motion
A Framer Motion optimization guide for React developers, with prioritized rules covering performance, layout, scroll, and gesture animations.
Key features
- 01Covers nine optimization categories
- 02Prioritizes rules by impact
- 03Offers animation coding guidance
- 04Includes reference files and a rule template
Use cases
- 01Optimize animation-heavy React applications
- 02Reduce unnecessary renders during animation
- 03Build layout, scroll, or gesture animations
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ pproenca/ dot-skills --skill framer-motionAfter installing, type/framer-motionin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
metadata.jsonassets/templates/_template.mdreferences/_sections.mdanim-hardware-acceleration.mdanim-independent-transforms.mdanim-keyframes-array.mdanim-opacity-filter.mdanim-transform-properties.mdanim-will-change.mdbundle-dom-animation.mdbundle-dynamic-features.mdbundle-lazy-motion.mdbundle-strict-mode.mdbundle-use-animate-mini.mdexit-animate-presence.mdexit-mode-wait.mdexit-unique-keys.mdgesture-drag-constraints.mdgesture-drag-elastic.mdgesture-tap-cancel.mdgesture-variants-flow.mdgesture-while-props.mdlayout-dependency.mdlayout-group.mdlayout-id-shared.mdlayout-position-size.mdlayout-scroll.mdrerender-animate-prop.mdrerender-motion-value-event.mdrerender-motion-value.mdDetails
From the project READMECommunity Framer Motion Best Practices
Comprehensive performance optimization guide for Framer Motion animations in React applications. Contains 42 rules across 9 categories, prioritized by impact to guide automated refactoring and code generation.
When to Apply
Reference these guidelines when:
- Adding animations to React components with Framer Motion
- Optimizing bundle size for animation-heavy applications
- Preventing unnecessary re-renders during animations
- Implementing layout transitions or shared element animations
- Building scroll-linked or gesture-based interactions
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Bundle Optimization | CRITICAL | bundle- |
| 2 | Re-render Prevention | CRITICAL | rerender- |
| 3 | Animation Properties | HIGH | anim- |
| 4 | Layout Animations | HIGH | layout- |
| 5 | Scroll Animations | MEDIUM-HIGH | scroll- |
| 6 | Gesture Optimization | MEDIUM | gesture- |
| 7 | Spring & Physics | MEDIUM | spring- |
| 8 | SVG & Path Animations | LOW-MEDIUM | svg- |
| 9 | Exit Animations | LOW | exit- |
Quick Reference
1. Bundle Optimization (CRITICAL)
bundle-lazy-motion- Use LazyMotion and m component instead of motionbundle-dynamic-features- Dynamically import motion featuresbundle-dom-animation- Use domAnimation for basic animationsbundle-use-animate-mini- Use mini useAnimate for simple casesbundle-strict-mode- Enable strict mode to catch accidental imports
2. Re-render Prevention (CRITICAL)
rerender-motion-value- Use useMotionValue instead of useStatererender-use-transform- Derive values with useTransformrerender-stable-callbacks- Keep animation callbacks stablererender-variants-object- Define variants outside componentrerender-animate-prop- Use stable animate valuesrerender-motion-value-event- Use motion value events
3. Animation Properties (HIGH)
anim-transform-properties- Animate transform propertiesanim-opacity-filter- Prefer opacity and filter for visual effectsanim-hardware-acceleration- Leverage hardware accelerationanim-will-change- Use willChange prop judiciouslyanim-independent-transforms- Animate transforms independentlyanim-keyframes-array- Use keyframe arrays for sequences
4. Layout Animations (HIGH)
layout-dependency- Use layoutDependency to limit measurementslayout-position-size- Use layout="position" or "size" appropriatelylayout-group- Group related layout animationslayout-id-shared- Use layoutId for shared element transitionslayout-scroll- Add layoutScroll to scrollable ancestors
5. Scroll Animations (MEDIUM-HIGH)
scroll-use-scroll- Use useScroll hook for scroll-linked animationsscroll-use-spring-smooth- Smooth scroll animations with useSpringscroll-element-tracking- Track specific elements entering viewportscroll-offset-configuration- Configure scroll offsetsscroll-container-ref- Track scroll within specific containers
6. Gesture Optimization (MEDIUM)
gesture-while-props- Use whileHover/whileTap instead of handlersgesture-variants-flow- Let gesture variants flow to childrengesture-drag-constraints- Use dragConstraints ref for boundariesgesture-drag-elastic- Configure dragElastic for natural feelgesture-tap-cancel- Use onTapCancel for interrupted gestures
7. Spring & Physics (MEDIUM)
spring-physics-based- Use physics-based springs for interruptibilityspring-damping-ratio- Configure damping to control oscillationspring-mass-inertia- Adjust mass for heavier/lighter feelspring-use-spring-hook- Use useSpring for reactive values
8. SVG & Path Animations (LOW-MEDIUM)
svg-path-length- Use pathLength for line drawing animationssvg-motion-components- Use motion.path and motion.circlesvg-viewbox-animation- Animate viewBox for zoom effectssvg-morph-matching-points- Match point counts for morphing
9. Exit Animations (LOW)
exit-animate-presence- Wrap conditional renders with AnimatePresenceexit-unique-keys- Provide unique keys for AnimatePresence childrenexit-mode-wait- Use mode="wait" for sequential transitions
How to Use
Read individual reference files for detailed explanations and code examples:
- Section definitions - Category structure and impact levels
- Rule template - Template for adding new rules
Reference Files
| File | Description |
|---|---|
| references/_sections.md | Category definitions and ordering |
| assets/templates/_template.md | Template for new rules |
| metadata.json | Version and reference information |
Comments
Markdown supported