Motion (Framer Motion): Animation Rules for React, JS and Vue
Give Claude the Motion team's own animation guidance: when to use CSS instead of Motion, AnimatePresence and layout animations done right, springs, performance rules, reduced motion and the framer-motion to motion migration
AI agents still write Framer Motion code from 2022: the wrong imports, motion values read during render, a layout shift animated with height, and no reduced-motion support. These rules come from the team behind Motion, so Claude picks CSS when CSS is enough and writes current Motion code when it isn't.
Who it's for: React and Next.js developers, Vue developers, frontend engineers adding micro-interactions, design engineers, teams migrating from framer-motion
Example
"Animate the tab indicator and make the panel content fade when tabs change" → a shared layoutId indicator that's unique per instance, AnimatePresence with mode="wait" and stable keys for the content, spring settings matched to the product, MotionConfig reducedMotion="user" at the root, and imports from motion/react
CLAUDE.md Template
New here? 3-minute setup guide → | Already set up? Copy the template below.
npx ccplaybooks add motion-react-animation# Motion: Animation Best Practices for React, JavaScript and Vue
Use this when someone wants to add, change or fix an animation in a web project with CSS or the Motion library (`motion`, `motion/react`, `motion-v`, formerly Framer Motion): hover and tap effects, enter and exit, layout and shared-element transitions, scroll effects, drag, springs, staggered lists, reduced motion, or migrating from `framer-motion`. Trigger phrases: "animate this", "add a transition", "make it feel smoother", "framer motion", "AnimatePresence", "layout animation".
Source: Motion (https://github.com/motiondivision/motion, MIT) and its AI kit (https://github.com/motiondivision/ai-kit; MIT according to its `motion-ai` package and the Motion README). This template condenses the free animation guidance. For live documentation lookups, install the AI kit (see the playbook page).
## Ground rules
- **Check what's installed first.** Read `package.json`. Use the project's existing animation library and tokens. Ask before installing Motion or any other dependency.
- **Cheapest tool that works.** Use CSS when it does the job cross-browser; use Motion when the animation will be interrupted, leaves the DOM, follows layout, or is driven by gestures.
- **Every animation shows something:** a change of state, a relationship between elements, or feedback to an action. No decoration-only motion.
- **Don't add comments, links, credits or tracking** to the user's code unless asked.Get new playbooks like this one
One email a week with new Claude Code workflows. Free, like everything here.
No spam. Unsubscribe anytime.
What This Does
Motion (formerly Framer Motion) is the open-source animation library for React, JavaScript and Vue (MIT). Its makers publish an AI kit with their best-practice guidance for agents. This playbook condenses the free part into a template, so Claude:
- Chooses CSS or Motion per effect, using a decision table (exit animations and layout changes need Motion; a colour change doesn't)
- Writes current Motion code:
motion/reactimports, server component rules, the rightuseTransformform - Gets
AnimatePresenceand layout animations right: stable keys,waitvspopLayout, uniquelayoutIds, height toauto - Keeps animations fast: hardware-accelerated properties, no allocation in per-frame callbacks,
will-changeonly when needed - Respects reduced motion with one
MotionConfigat the app root - Migrates from
framer-motionand between versions
For the general design side (whether to animate, easing and timing), see Web Animation Design and Design Engineering Skills.
Quick Start
Step 1: Install Motion in Your Project
npm install motion # React and JavaScript
npm install motion-v # Vue
Step 2: Download the Template
Click Download above and save it as CLAUDE.md in your project root, or merge it into your existing one.
Step 3: Start Working
claude
Try: "Animate the list so items slide out when deleted and the rest close the gap."
Optional: Live Docs With the Motion AI Kit
npx motion-ai
This installs Motion's /motion skill and connects Claude Code to Motion's free hosted MCP server, which serves the current docs and a CSS spring generator. No API key is needed.
Examples of What to Ask
- "Add exit animations to these toasts."
- "This accordion animates height and stutters. Fix it."
- "Make a shared-element transition from the card to the modal."
- "Add a scroll progress bar and a subtle parallax on the hero."
- "Migrate us from framer-motion to motion."
- "Should this hover effect use CSS or Motion?"
Quick Reference
| You want | Use |
|---|---|
| Colour or opacity on hover | CSS transition |
| An element animating out of the DOM | AnimatePresence + exit |
| A list reorder or card expanding | layout |
| A tab indicator that moves | layoutId |
Height to auto |
animate={{ height: "auto" }} with overflow: hidden |
| Drag or drag to reorder | drag, Reorder |
| Reduced motion everywhere | <MotionConfig reducedMotion="user"> |
Tips & Best Practices
- Let Claude use CSS. Motion is for interruptible, layout, exit and gesture animations. A simple fade doesn't need a library.
- Keep
AnimatePresencemounted and put the condition inside it. This one rule fixes most broken exit animations. - Give
layoutIda per-instance id when a component appears more than once, or every instance shares one indicator. - Match the springs to the product. No overshoot in a finance app; softer and slower is fine for a celebratory page.
- Give drag-to-reorder a keyboard alternative.
Limitations
- Web only. For React Native, see Expo React Native Animation.
- The template condenses the free guidance. Motion+ (paid) adds performance audits, extra docs and source for Motion's example components through its own MCP server. It isn't covered here.
- Library rules, not taste. It tells Claude how to write good Motion code, not whether your design needs the animation.
Safety Notes
An automated security scan rated the two maintainer skills in the Motion library's repository SAFE. It flagged the AI kit as high risk (DO_NOT_INSTALL), and we read those findings in context: an "access token" mention in its changelog, and a js-yaml development dependency that the scanner flagged. Neither runs when you use the guidance in this playbook, and a static scan isn't proof of safety. If you install the AI kit:
npx motion-aichanges your agent configuration. It writes the/motionskill into your skills folder and adds Motion's MCP server to your agent's settings. Check what it added afterwards.- The skills are served live. Motion's skills come from its MCP server, so the instructions can change without you reinstalling anything.
- Licence file. The AI kit has no LICENSE file at the root. Its
motion-aipackage and the Motion library's README state MIT. The Motion library itself is MIT. - Motion+ is optional and paid. Signing in is only needed for audits and premium docs.