File contents Community 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 motion
bundle-dynamic-features - Dynamically import motion features
bundle-dom-animation - Use domAnimation for basic animations
bundle-use-animate-mini - Use mini useAnimate for simple cases
bundle-strict-mode - Enable strict mode to catch accidental imports
2. Re-render Prevention (CRITICAL)
rerender-motion-value - Use useMotionValue instead of useState
rerender-use-transform - Derive values with useTransform
rerender-stable-callbacks - Keep animation callbacks stable
rerender-variants-object - Define variants outside component
rerender-animate-prop - Use stable animate values
rerender-motion-value-event - Use motion value events
3. Animation Properties (HIGH)
anim-transform-properties - Animate transform properties
anim-opacity-filter - Prefer opacity and filter for visual effects
anim-hardware-acceleration - Leverage hardware acceleration
anim-will-change - Use willChange prop judiciously
anim-independent-transforms - Animate transforms independently
anim-keyframes-array - Use keyframe arrays for sequences
4. Layout Animations (HIGH)
layout-dependency - Use layoutDependency to limit measurements
layout-position-size - Use layout="position" or "size" appropriately
layout-group - Group related layout animations
layout-id-shared - Use layoutId for shared element transitions
layout-scroll - Add layoutScroll to scrollable ancestors
5. Scroll Animations (MEDIUM-HIGH)
scroll-use-scroll - Use useScroll hook for scroll-linked animations
scroll-use-spring-smooth - Smooth scroll animations with useSpring
scroll-element-tracking - Track specific elements entering viewport
scroll-offset-configuration - Configure scroll offsets
scroll-container-ref - Track scroll within specific containers
6. Gesture Optimization (MEDIUM)
gesture-while-props - Use whileHover/whileTap instead of handlers
gesture-variants-flow - Let gesture variants flow to children
gesture-drag-constraints - Use dragConstraints ref for boundaries
gesture-drag-elastic - Configure dragElastic for natural feel
gesture-tap-cancel - Use onTapCancel for interrupted gestures
7. Spring & Physics (MEDIUM)
spring-physics-based - Use physics-based springs for interruptibility
spring-damping-ratio - Configure damping to control oscillation
spring-mass-inertia - Adjust mass for heavier/lighter feel
spring-use-spring-hook - Use useSpring for reactive values
8. SVG & Path Animations (LOW-MEDIUM)
svg-path-length - Use pathLength for line drawing animations
svg-motion-components - Use motion.path and motion.circle
svg-viewbox-animation - Animate viewBox for zoom effects
svg-morph-matching-points - Match point counts for morphing
9. Exit Animations (LOW)
exit-animate-presence - Wrap conditional renders with AnimatePresence
exit-unique-keys - Provide unique keys for AnimatePresence children
exit-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
1 --- 2 name: framer-motion 3 description: Community Framer Motion Best Practices 4 --- 5 # Community Framer Motion Best Practices 6 7 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. 8 9 ## When to Apply 10 11 Reference these guidelines when: 12 - Adding animations to React components with Framer Motion 13 - Optimizing bundle size for animation-heavy applications 14 - Preventing unnecessary re-renders during animations 15 - Implementing layout transitions or shared element animations 16 - Building scroll-linked or gesture-based interactions 17 18 ## Rule Categories by Priority 19 20 | Priority | Category | Impact | Prefix | 21 |----------|----------|--------|--------| 22 | 1 | Bundle Optimization | CRITICAL | `bundle-` | 23 | 2 | Re-render Prevention | CRITICAL | `rerender-` | 24 | 3 | Animation Properties | HIGH | `anim-` | 25 | 4 | Layout Animations | HIGH | `layout-` | 26 | 5 | Scroll Animations | MEDIUM-HIGH | `scroll-` | 27 | 6 | Gesture Optimization | MEDIUM | `gesture-` | 28 | 7 | Spring & Physics | MEDIUM | `spring-` | 29 | 8 | SVG & Path Animations | LOW-MEDIUM | `svg-` | 30 | 9 | Exit Animations | LOW | `exit-` | 31 32 ## Quick Reference 33 34 ### 1. Bundle Optimization (CRITICAL) 35 36 - [`bundle-lazy-motion`](references/bundle-lazy-motion.md) - Use LazyMotion and m component instead of motion 37 - [`bundle-dynamic-features`](references/bundle-dynamic-features.md) - Dynamically import motion features 38 - [`bundle-dom-animation`](references/bundle-dom-animation.md) - Use domAnimation for basic animations 39 - [`bundle-use-animate-mini`](references/bundle-use-animate-mini.md) - Use mini useAnimate for simple cases 40 - [`bundle-strict-mode`](references/bundle-strict-mode.md) - Enable strict mode to catch accidental imports 41 42 ### 2. Re-render Prevention (CRITICAL) 43 44 - [`rerender-motion-value`](references/rerender-motion-value.md) - Use useMotionValue instead of useState 45 - [`rerender-use-transform`](references/rerender-use-transform.md) - Derive values with useTransform 46 - [`rerender-stable-callbacks`](references/rerender-stable-callbacks.md) - Keep animation callbacks stable 47 - [`rerender-variants-object`](references/rerender-variants-object.md) - Define variants outside component 48 - [`rerender-animate-prop`](references/rerender-animate-prop.md) - Use stable animate values 49 - [`rerender-motion-value-event`](references/rerender-motion-value-event.md) - Use motion value events 50 51 ### 3. Animation Properties (HIGH) 52 53 - [`anim-transform-properties`](references/anim-transform-properties.md) - Animate transform properties 54 - [`anim-opacity-filter`](references/anim-opacity-filter.md) - Prefer opacity and filter for visual effects 55 - [`anim-hardware-acceleration`](references/anim-hardware-acceleration.md) - Leverage hardware acceleration 56 - [`anim-will-change`](references/anim-will-change.md) - Use willChange prop judiciously 57 - [`anim-independent-transforms`](references/anim-independent-transforms.md) - Animate transforms independently 58 - [`anim-keyframes-array`](references/anim-keyframes-array.md) - Use keyframe arrays for sequences 59 60 ### 4. Layout Animations (HIGH) 61 62 - [`layout-dependency`](references/layout-dependency.md) - Use layoutDependency to limit measurements 63 - [`layout-position-size`](references/layout-position-size.md) - Use layout="position" or "size" appropriately 64 - [`layout-group`](references/layout-group.md) - Group related layout animations 65 - [`layout-id-shared`](references/layout-id-shared.md) - Use layoutId for shared element transitions 66 - [`layout-scroll`](references/layout-scroll.md) - Add layoutScroll to scrollable ancestors 67 68 ### 5. Scroll Animations (MEDIUM-HIGH) 69 70 - [`scroll-use-scroll`](references/scroll-use-scroll.md) - Use useScroll hook for scroll-linked animations 71 - [`scroll-use-spring-smooth`](references/scroll-use-spring-smooth.md) - Smooth scroll animations with useSpring 72 - [`scroll-element-tracking`](references/scroll-element-tracking.md) - Track specific elements entering viewport 73 - [`scroll-offset-configuration`](references/scroll-offset-configuration.md) - Configure scroll offsets 74 - [`scroll-container-ref`](references/scroll-container-ref.md) - Track scroll within specific containers 75 76 ### 6. Gesture Optimization (MEDIUM) 77 78 - [`gesture-while-props`](references/gesture-while-props.md) - Use whileHover/whileTap instead of handlers 79 - [`gesture-variants-flow`](references/gesture-variants-flow.md) - Let gesture variants flow to children 80 - [`gesture-drag-constraints`](references/gesture-drag-constraints.md) - Use dragConstraints ref for boundaries 81 - [`gesture-drag-elastic`](references/gesture-drag-elastic.md) - Configure dragElastic for natural feel 82 - [`gesture-tap-cancel`](references/gesture-tap-cancel.md) - Use onTapCancel for interrupted gestures 83 84 ### 7. Spring & Physics (MEDIUM) 85 86 - [`spring-physics-based`](references/spring-physics-based.md) - Use physics-based springs for interruptibility 87 - [`spring-damping-ratio`](references/spring-damping-ratio.md) - Configure damping to control oscillation 88 - [`spring-mass-inertia`](references/spring-mass-inertia.md) - Adjust mass for heavier/lighter feel 89 - [`spring-use-spring-hook`](references/spring-use-spring-hook.md) - Use useSpring for reactive values 90 91 ### 8. SVG & Path Animations (LOW-MEDIUM) 92 93 - [`svg-path-length`](references/svg-path-length.md) - Use pathLength for line drawing animations 94 - [`svg-motion-components`](references/svg-motion-components.md) - Use motion.path and motion.circle 95 - [`svg-viewbox-animation`](references/svg-viewbox-animation.md) - Animate viewBox for zoom effects 96 - [`svg-morph-matching-points`](references/svg-morph-matching-points.md) - Match point counts for morphing 97 98 ### 9. Exit Animations (LOW) 99 100 - [`exit-animate-presence`](references/exit-animate-presence.md) - Wrap conditional renders with AnimatePresence 101 - [`exit-unique-keys`](references/exit-unique-keys.md) - Provide unique keys for AnimatePresence children 102 - [`exit-mode-wait`](references/exit-mode-wait.md) - Use mode="wait" for sequential transitions 103 104 ## How to Use 105 106 Read individual reference files for detailed explanations and code examples: 107 108 - [Section definitions](references/_sections.md) - Category structure and impact levels 109 - [Rule template](assets/templates/_template.md) - Template for adding new rules 110 111 ## Reference Files 112 113 | File | Description | 114 |------|-------------| 115 | [references/_sections.md](references/_sections.md) | Category definitions and ordering | 116 | [assets/templates/_template.md](assets/templates/_template.md) | Template for new rules | 117 | [metadata.json](metadata.json) | Version and reference information |
ComeOnOliver/skillshub/tree/main/skills/pproenca/dot-skills/framer-motion commit 01306e637e
Frequently asked questions How do I install the Framer Motion skill? Run npx skillmds@latest add comeonoliver/framer-motion in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
What does the Framer Motion skill do? Community Framer Motion Best Practices It is listed under Coding & Dev Tools on SkillMD.
Is Framer Motion safe to use? This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
Which AI agents work with Framer Motion? This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Is Framer Motion free to use? Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
Who published Framer Motion? ComeOnOliver (@comeonoliver) published this skill. Their other Agent Skills are listed on their SkillMD profile.