install
source · Clone the upstream repo
git clone https://github.com/ComeOnOliver/skillshub
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/pproenca/dot-skills/framer-motion" ~/.claude/skills/comeonoliver-skillshub-framer-motion-0d2f75 && rm -rf "$T"
manifest:
skills/pproenca/dot-skills/framer-motion/SKILL.mdsource content
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 | |
| 2 | Re-render Prevention | CRITICAL | |
| 3 | Animation Properties | HIGH | |
| 4 | Layout Animations | HIGH | |
| 5 | Scroll Animations | MEDIUM-HIGH | |
| 6 | Gesture Optimization | MEDIUM | |
| 7 | Spring & Physics | MEDIUM | |
| 8 | SVG & Path Animations | LOW-MEDIUM | |
| 9 | Exit Animations | LOW | |
Quick Reference
1. Bundle Optimization (CRITICAL)
- Use LazyMotion and m component instead of motionbundle-lazy-motion
- Dynamically import motion featuresbundle-dynamic-features
- Use domAnimation for basic animationsbundle-dom-animation
- Use mini useAnimate for simple casesbundle-use-animate-mini
- Enable strict mode to catch accidental importsbundle-strict-mode
2. Re-render Prevention (CRITICAL)
- Use useMotionValue instead of useStatererender-motion-value
- Derive values with useTransformrerender-use-transform
- Keep animation callbacks stablererender-stable-callbacks
- Define variants outside componentrerender-variants-object
- Use stable animate valuesrerender-animate-prop
- Use motion value eventsrerender-motion-value-event
3. Animation Properties (HIGH)
- Animate transform propertiesanim-transform-properties
- Prefer opacity and filter for visual effectsanim-opacity-filter
- Leverage hardware accelerationanim-hardware-acceleration
- Use willChange prop judiciouslyanim-will-change
- Animate transforms independentlyanim-independent-transforms
- Use keyframe arrays for sequencesanim-keyframes-array
4. Layout Animations (HIGH)
- Use layoutDependency to limit measurementslayout-dependency
- Use layout="position" or "size" appropriatelylayout-position-size
- Group related layout animationslayout-group
- Use layoutId for shared element transitionslayout-id-shared
- Add layoutScroll to scrollable ancestorslayout-scroll
5. Scroll Animations (MEDIUM-HIGH)
- Use useScroll hook for scroll-linked animationsscroll-use-scroll
- Smooth scroll animations with useSpringscroll-use-spring-smooth
- Track specific elements entering viewportscroll-element-tracking
- Configure scroll offsetsscroll-offset-configuration
- Track scroll within specific containersscroll-container-ref
6. Gesture Optimization (MEDIUM)
- Use whileHover/whileTap instead of handlersgesture-while-props
- Let gesture variants flow to childrengesture-variants-flow
- Use dragConstraints ref for boundariesgesture-drag-constraints
- Configure dragElastic for natural feelgesture-drag-elastic
- Use onTapCancel for interrupted gesturesgesture-tap-cancel
7. Spring & Physics (MEDIUM)
- Use physics-based springs for interruptibilityspring-physics-based
- Configure damping to control oscillationspring-damping-ratio
- Adjust mass for heavier/lighter feelspring-mass-inertia
- Use useSpring for reactive valuesspring-use-spring-hook
8. SVG & Path Animations (LOW-MEDIUM)
- Use pathLength for line drawing animationssvg-path-length
- Use motion.path and motion.circlesvg-motion-components
- Animate viewBox for zoom effectssvg-viewbox-animation
- Match point counts for morphingsvg-morph-matching-points
9. Exit Animations (LOW)
- Wrap conditional renders with AnimatePresenceexit-animate-presence
- Provide unique keys for AnimatePresence childrenexit-unique-keys
- Use mode="wait" for sequential transitionsexit-mode-wait
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 |