Skip to content

@tank/framer-motion

1.1.0
Skill

Description

Motion for React animation mastery. Covers motion component, AnimatePresence, layout animations, spring physics, scroll animations, gestures, motion values, useAnimate, variants, drag, LazyMotion, and accessibility.

Triggered by

framer motionmotion/reactAnimatePresencelayout animationlayoutIdspring animation
Download
Unsafe
tank install @tank/framer-motion

Motion for React

Core Philosophy

  1. Springs over tweens — Spring physics feel natural because they incorporate velocity. Default to springs for movement (x, y, scale), tweens for visual properties (opacity, color).
  2. Motion values over React state — Motion values update the DOM directly without re-renders. Use them for anything that changes rapidly (scroll, mouse, continuous animation).
  3. Declarative first, imperative when needed — Use animate, whileHover, variants for 90% of work. Reach for useAnimate only for sequences, timeline scrubbing, or event-driven triggers.
  4. Layout animations are magic — The layout prop and layoutId handle FLIP animations with scale-distortion correction. Use them for any position/size change.
  5. Respect the user — Always check useReducedMotion(). Replace movement with opacity-only transitions when reduced motion is preferred.

Quick-Start

"How do I animate something?"

import { motion } from "motion/react"

<motion.div
  initial={{ opacity: 0, y: 20 }}
  animate={{ opacity: 1, y: 0 }}
  transition={{ type: "spring", stiffness: 400, damping: 30 }}
/>

-> See references/core-animation-api.md

"How do I animate exit/removal?"

Wrap conditionally rendered elements in AnimatePresence:

<AnimatePresence mode="wait">
  {show && <motion.div key="item" exit={{ opacity: 0 }} />}
</AnimatePresence>

-> See references/core-animation-api.md

"How do I tune spring feel?"

FeelConfigUse Case
Snappystiffness: 400, damping: 30Buttons, toggles
Bouncystiffness: 300, damping: 12Notifications, playful UI
Smoothstiffness: 200, damping: 20Dialogs, drawers
Gentlestiffness: 120, damping: 14Background, subtle shifts

-> See references/transitions-and-springs.md

"How do I do shared element transitions?"

Use layoutId to morph between different components:

<motion.div layoutId={`card-${id}`} />

-> See references/layout-animations.md

"How do I animate on scroll?"

const { scrollYProgress } = useScroll()
const opacity = useTransform(scrollYProgress, [0, 1], [0, 1])

-> See references/scroll-and-viewport.md

"I need a complete animation recipe"

Copy-paste production patterns for modals, page transitions, staggered lists, button states, drag-to-dismiss, SVG drawing, and more. -> See references/production-recipes.md

Decision Trees

Which Transition Type?

Property TypeDefaultOverride To
Physical (x, y, scale, rotate)SpringTween only if duration matters
Visual (opacity, color, filter)Tween (0.3s)Spring for bouncy feel
Layout (layout prop)SpringTween for controlled timing
Exit animationsSame as animateFaster duration (0.15-0.2s)

Which Animation Approach?

NeedApproachAPI
Simple state changeDeclarativeanimate={{ }}
Gesture feedbackDeclarativewhileHover, whileTap
Enter/exit the DOMDeclarativeAnimatePresence + exit
Coordinated childrenDeclarativevariants + staggerChildren
Position/size changeDeclarativelayout / layoutId
Scroll-linkedReactiveuseScroll + useTransform
Complex sequenceImperativeuseAnimate
Continuous/high-freqReactiveuseMotionValue

When NOT to Use Motion

SituationUse Instead
Simple hover color changeCSS transition
Single property opacity fadeCSS transition
Continuous keyframe loop (non-interactive)CSS @keyframes
Canvas/WebGL animationThree.js / PixiJS
60fps scroll effects on 100+ elementsCSS scroll-timeline

Import Note

The library was renamed from framer-motion to motion. Use the new import:

// Correct (v11+)
import { motion, AnimatePresence } from "motion/react"

// Legacy (still works but deprecated)
import { motion, AnimatePresence } from "framer-motion"

Reference Files

FileContents
references/core-animation-api.mdmotion component, animate/initial/exit, AnimatePresence, keyframes, variants, orchestration, useAnimate, animatable values
references/transitions-and-springs.mdSpring physics (stiffness/damping/mass vs bounce/duration), tween easing, inertia, spring presets, tuning guide, orchestration timing
references/layout-animations.mdlayout prop, layoutId, LayoutGroup, shared element transitions, Reorder component, FLIP correction, common gotchas
references/gestures-and-drag.mdwhileHover/whileTap/whileFocus/whileDrag/whileInView, drag constraints, useDragControls, event propagation, accessibility
references/scroll-and-viewport.mduseScroll, scroll-linked animations, parallax, progress bars, useInView, viewport options
references/motion-values-and-hooks.mduseMotionValue, useTransform, useSpring, useVelocity, useMotionTemplate, useMotionValueEvent, useAnimate, useAnimationFrame, useReducedMotion
references/production-recipes.mdPage transitions, modal animations, staggered lists, tab switchers, accordions, SVG path drawing, drag-to-dismiss, button states, shared elements
references/performance-and-accessibility.mdGPU acceleration tiers, LazyMotion code splitting, MotionConfig, bundle size, reduced motion, animation duration guidelines, anti-patterns, SSR/RSC

Command Palette

Search packages, docs, and navigate Tank