Home
cd ../playbooks
Developer ToolsIntermediate

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

5 minutes
By motiondivisionSource
#motion#framer-motion#react#animation#vue#css-animation#nextjs#frontend

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.

Or install from your terminal:
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.

README.md

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/react imports, server component rules, the right useTransform form
  • Gets AnimatePresence and layout animations right: stable keys, wait vs popLayout, unique layoutIds, height to auto
  • Keeps animations fast: hardware-accelerated properties, no allocation in per-frame callbacks, will-change only when needed
  • Respects reduced motion with one MotionConfig at the app root
  • Migrates from framer-motion and 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 AnimatePresence mounted and put the condition inside it. This one rule fixes most broken exit animations.
  • Give layoutId a 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-ai changes your agent configuration. It writes the /motion skill 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-ai package 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.

$Related Playbooks

Developer Tools

Multi-Stage Prompt Pipeline

A methodology for building Claude-to-Claude prompt pipelines where one stage's output feeds the next — a four-purpose taxonomy (Research/Plan/Do/Refine), per-prompt provenance folders, XML-structured outputs with required metadata tags, a fixed human-scannable SUMMARY.md, dependency-aware layered execution, and per-stage validation before anything chains forward.

10 minutes
Advanced
Developer Tools

Nuxt UI Component Guidance

Build interfaces correctly with @nuxt/ui v4 — five core rules (UApp wrapper, semantic colors, reading generated theme files for real slot names, override priority, icon naming), a task-to-focus-area routing table, the Nuxt UI MCP server for live component API lookups, and full installation for both Nuxt and standalone Vue.

5 minutes
Beginner
Developer Tools

n8n Workflow Builder

Automate document workflows with n8n - 7800+ workflow templates

10 minutes
Advanced
Developer Tools

Office MCP Server Setup

MCP server with 39 tools for Word, Excel, PowerPoint, PDF, OCR operations

10 minutes
Intermediate
Developer Tools

Frontend Enhancer

Enhance Next.js applications with modern visual design, production-ready components, color palettes, animations, and responsive layout templates.

10 minutes
Intermediate
Developer Tools

Saga Orchestration for Distributed Transactions

Implement the saga pattern for multi-step workflows that span services and can't use a single ACID transaction — choreography vs. orchestration, a step/compensation model with explicit saga states, reverse-order compensation on failure, persisted saga state that survives an orchestrator restart, timeouts, and the idempotency and compensation-testing discipline that makes rollback actually work.

15 minutes
Advanced
Developer Tools

Reshape PR Commits

Turn a branch's messy WIP/fixup commit history into a clean, logically-grouped set of commits before review — proposed regrouping with explicit approval, git reset --soft plus staged re-commits instead of interactive rebase, and hard guardrails (feature branches only, force-with-lease only, never touch another author's commits).

5 minutes
Intermediate
Developer Tools

Reproducible Database Lookup

A methodology for querying public database APIs — scientific, regulatory, financial, or otherwise — so another agent or human can repeat exactly what you did: bounded calls, count reconciliation, identifier-conversion tracking, and untrusted-data handling for every response.

10 minutes
Advanced
Developer Tools

Redesign Existing Projects: UI Audit and Upgrade

A design audit checklist that finds generic AI-look patterns in an existing codebase and fixes them without breaking functionality or migrating frameworks

10 minutes
Intermediate
Developer Tools

Repomix Safe Mixer

Package codebases with repomix while automatically detecting and removing hardcoded credentials before packing — so you never leak secrets when sharing code.

5 minutes
Beginner
Developer Tools

Repomix Unmixer

Extract files from repomix-packed repositories — restore the original directory structure from XML, Markdown, or JSON output, reversing the packing process.

5 minutes
Beginner
Developer Tools

Release Notes Generator

Generate release notes, changelogs, and announcement copy from diffs and PR summaries - with upgrade notes and test checklist.

5 minutes
Beginner

Browse all Developer Tools playbooks →