react-animations
Motion for React (the `motion` package): choosing between CSS and Motion, exit animations, reduced-motion handling, bundle size, and game HUD effects such as…
от fcsouza★ 29 звёзд на GitHub
Установить react-animations в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
React animations with Motion
Motion is the library formerly named Framer Motion. framer-motion publishes the same code under the old name, so existing projects keep working. New code installs motion and imports from motion/react.
Use the official Motion tooling first
Use the motion skill (Motion AI Kit) if it is installed, otherwise run bunx motion-ai or read https://github.com/motiondivision/ai-kit. It also configures the docs MCP server at https://mcp.motion.dev. For API details, read https://motion.dev/llms.txt. Every docs page serves Markdown when you add .md to its URL. This skill keeps only the decisions and the game-UI recipes those sources do not hold.
Choose the tool
| Need | Use |
|---|---|
| Hover, focus, simple fades | CSS transition (Tailwind). Do not add Motion for this. |
Enter and exit of conditional elements, variants, gestures, drag, layout and layoutId |
motion components with AnimatePresence |
| Values driven by input or game state (bars, counters) | useMotionValue, useSpring, useTransform |
| One-off imperative sequences (shake, pulse) | useAnimate |
| Timelines, ScrollTrigger, SVG drawing | GSAP. Use the gsap-react skill. |
| Native page and route transitions | The vercel-react-view-transitions skill. Use Motion's AnimateView (import { AnimateView } from 'motion/react-animate-view', not motion/react) only if the project already uses Motion. It needs React and React DOM 19.3 or later. |
Setup
bun add motion
import { motion } from 'motion/react';
In a Next.js App Router server file, use import * as motion from 'motion/react-client'. Otherwise add 'use client'.
Rules that save debugging time
- Animate
transformandopacity. Animatingwidth,height,toporleftforces layout work. UsescaleX,scaleYor thelayoutprop. - Wrap conditional elements in
AnimatePresence, orexitnever runs. Give each child a stablekey. - Put variants outside the component so they keep one identity.
- Drive animation values with motion values, not
useState. Motion values update without re-rendering the component. - Do not mix a CSS
transitionand Motion on one element. They fight over the same property. - An element animates on mount from its first-rendered values to
animate. Setinitialto choose the start. If those values already matchanimate, nothing plays.initial={false}renders at theanimatevalues with no enter animation. - Call
motion.create(Component)at module level, never inside a render. The component you wrap must forward itsref.
AnimatePresence modes: "sync" (default), "wait" (one child only), "popLayout" (custom children must forward ref; give the animating parent a non-static position).
Reduced motion
Set it once at the app root:
import { MotionConfig } from 'motion/react';
<MotionConfig reducedMotion="user">
<App />
</MotionConfig>
"user" turns off transform and layout animations. It keeps animations of other values such as opacity and backgroundColor. It does not stop every animation. For effects that are large movement by design (shake, parallax, big slides), read useReducedMotion() and skip or swap them for a fade. ScreenShake in boilerplate/motion-components.tsx does this. "always" and "never" let a user setting override the OS value. useReducedMotion() reports the device setting. Do not rely on it to reflect a MotionConfig override.
Bundle size
motion is about 43 kB gzipped. LazyMotion with m starts near 5 kB. Add domAnimation (+24 kB) for animations, variants, exit and hover, tap and focus gestures. Add domMax (+38 kB) for drag and layout animations instead.
import { LazyMotion, domAnimation } from 'motion/react';
import * as m from 'motion/react-m';
<LazyMotion features={domAnimation}>
<m.div animate={{ opacity: 1 }} />
</LazyMotion>
Pass strict to LazyMotion to throw if a motion component slips in. useAnimate has a mini version at motion/react-mini, about 3.3 kB, that runs on WAAPI only.
Game HUD recipes
The working code is in boilerplate/motion-components.tsx. Copy the component, then adjust numbers.
| Effect | Component | How it works |
|---|---|---|
| Health or XP bar | HealthBar |
useSpring on a motion value, applied as scaleX with transformOrigin: 'left'. Clamp the ratio to 0..1. |
| Damage or score pop-up | FloatingNumber |
Animates y and opacity, calls onComplete so the parent removes it. |
| Card flip | AnimatedCard |
See below. |
| Screen shake | ScreenShake |
useAnimate on a keyframe array of x, skipped under reduced motion. |
| Menu slide | SlideIn inside AnimatePresence |
Ease on x; under reduced motion it drops the x offset and keeps a short opacity fade. |
Card flip needs three things. Put perspective on the parent. Put transformStyle: 'preserve-3d' on the element that rotates. Give each face `
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- boilerplate/motion-components.tsx
- references/sources.md
- templates/animation-variants.ts
FAQ
Что делает скилл react-animations?
Motion for React (the `motion` package): choosing between CSS and Motion, exit animations, reduced-motion handling, bundle size, and game HUD effects such as health bars, damage numbers, card flips and screen shake. Use when adding or fixing in-component animation in a React app that uses, or should use, Motion. Not for other animation libraries or for route changes.
Как установить скилл react-animations?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл react-animations запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
frontend-design
AnthropicGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
webapp-testing
AnthropicToolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
brand-guidelines
AnthropicApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
web-artifacts-builder
AnthropicSuite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…