Communitygithub.com

Motion (Framer Motion) — React UIアニメーションライブラリ

React向けの宣言的アニメーションライブラリ。スプリング、ジェスチャー、レイアウトアニメーション、ページトランジションを提供。GPUアクセラレーション対応、プロダクション品質。

Motion (Framer Motion) — React UIアニメーションライブラリ とは?

Motion(旧Framer Motion)は、Reactアプリケーション向けのプロダクション品質の宣言的アニメーションライブラリです。GPUアクセラレーションを活用し、スプリング物理、ジェスチャー(ホバー、タップ、ドラッグ)、レイアウトアニメーション、スクロール連動アニメーション、ページトランジションなどを直感的なJSX propsで実現します。TypeScript/Reactで構築され、MITライセンスで公開されています。このスキルは、Claude CodeやCursor、CodexなどのAIエージェントがMotionライブラリを使用してReact UIアニメーションを実装する際に必要な、コアAPI、基本的なアニメーション、バリアントによるオーケストレーション、ジェスチャー、レイアウトアニメーション、スクロールアニメーション、useAnimateによる命令的制御、トランジションタイプ、共通パターン(ページトランジション、段階的リスト、ホバーカード)などのベストプラクティスを網羅しています。これらの知識を活用することで、AIエージェントはユーザーエクスペリエンスを向上させる、スムーズでパフォーマンスの高いReact UIアニメーションを効率的に生成できます。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ever-just/agentskills/tree/HEAD/skills/framer-motion

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

Motion(Framer Motion) — React UIアニメーションライブラリ

React向けの宣言的アニメーション。スプリング、ジェスチャー、レイアウトアニメーション、ページトランジション。GPUアクセラレーション対応、プロダクション品質。

概要

  • リポジトリ: github.com/motiondivision/motion(26K以上のスター)
  • 言語: TypeScript / React
  • ライセンス: MIT
  • インストール: npm install motion
  • ドキュメント: motion.dev
  • 注意: Framer MotionはMotionに名称変更されました。motion/reactからインポートします。

コアAPI

基本アニメーション

import { motion } from "motion/react";

// マウント時にアニメーション
<motion.div
  initial={{ opacity: 0, y: 20 }}
  animate={{ opacity: 1, y: 0 }}
  transition={{ duration: 0.5 }}
>
  Hello World
</motion.div>

// アンマウント時にアニメーション(AnimatePresenceが必要)
import { AnimatePresence } from "motion/react";

<AnimatePresence>
  {isVisible && (
    <motion.div
      initial={{ opacity: 0 }}
      animate={{ opacity: 1 }}
      exit={{ opacity: 0 }}
    >
      コンテンツ
    </motion.div>
  )}
</AnimatePresence>

スプリング物理

<motion.div
  animate={{ x: 100 }}
  transition={{
    type: "spring",
    stiffness: 300,
    damping: 20,
    mass: 1,
  }}
/>

// プリセット
transition={{ type: "spring", bounce: 0.5 }}  // 0 = バウンドなし、1 = 非常にバウンドあり

バリアント(オーケストレーションアニメーション)

const container = {
  hidden: { opacity: 0 },
  show: {
    opacity: 1,
    transition: {
      staggerChildren: 0.1,    // 子要素間の遅延
      delayChildren: 0.3,       // 初期遅延
    },
  },
};

const item = {
  hidden: { opacity: 0, y: 20 },
  show: { opacity: 1, y: 0 },
};

<motion.ul variants={container} initial="hidden" animate="show">
  {items.map((i) => (
    <motion.li key={i} variants={item}>{i}</motion.li>
  ))}
</motion.ul>

ジェスチャー

// ホバー
<motion.button
  whileHover={{ scale: 1.05 }}
  whileTap={{ scale: 0.95 }}
>
  クリックしてね
</motion.button>

// ドラッグ
<motion.div
  drag                          // 両軸のドラッグを有効化
  dragConstraints={{ left: -100, right: 100, top: -50, bottom: 50 }}
  dragElastic={0.2}
/>

レイアウトアニメーション

// レイアウト変更を自動的にアニメーション
<motion.div layout>
  {isExpanded ? <ExpandedContent /> : <CollapsedContent />}
</motion.div>

// 共有レイアウトアニメーション(要素間でモーフィング)
<motion.div layoutId="card">
  {/* この要素はlayoutIdが一致すると位置がモーフィングします */}
</motion.div>

スクロールアニメーション

import { useScroll, useTransform, motion } from "motion/react";

function ParallaxSection() {
  const { scrollYProgress } = useScroll();
  const y = useTransform(scrollYProgress, [0, 1], [0, -200]);
  const opacity = useTransform(scrollYProgress, [0, 0.5, 1], [1, 1, 0]);

  return (
    <motion.div style={{ y, opacity }}>
      パララックスコンテンツ
    </motion.div>
  );
}

useAnimate(命令的制御)

import { useAnimate } from "motion/react";

function MyComponent() {
  const [scope, animate] = useAnimate();

  async function handleClick() {
    await animate(".box", { scale: 1.5 }, { duration: 0.3 });
    await animate(".box", { rotate: 360 }, { duration: 0.5 });
    await animate(".box", { scale: 1, rotate: 0 });
  }

  return (
    <div ref={scope}>
      <div className="box" onClick={handleClick}>クリックしてね</div>
    </div>
  );
}

キーフレーム

<motion.div
  animate={{
    x: [0, 100, 100, 0, 0],
    y: [0, 0, 100, 100, 0],
    rotate: [0, 90, 180, 270, 360],
  }}
  transition={{ duration: 2, repeat: Infinity }}
/>

トランジションタイプ

// スプリング(物理的な値のデフォルト)
transition={{ type: "spring", stiffness: 100, damping: 10 }}

// トゥイーン(持続時間ベース)
transition={{ type: "tween", duration: 0.5, ease: "easeInOut" }}

// イージングオプション
ease: "linear" | "easeIn" | "easeOut" | "easeInOut"
ease: [0.42, 0, 0.58, 1]  // カスタム3次ベジェ

// 繰り返し
transition={{ repeat: Infinity, repeatType: "reverse", duration: 1 }}

// 遅延
transition={{ delay: 0.5 }}

共通パターン

ページトランジション

// レイアウトコンポーネント内
<AnimatePresence mode="wait">
  <motion.div
    key={pathname}
    initial={{ opacity: 0, x: 20 }}
    animate={{ opacity: 1, x: 0 }}
    exit={{ opacity: 0, x: -20 }}
    transition={{ duration: 0.3 }}
  >
    {children}
  </motion.div>
</AnimatePresence>

段階的リスト

const container = {
  hidden: {},
  show: { transition: { staggerChildren: 0.08 } },
};
const item = {
  hidden: { opacity: 0, y: 15 },
  show: { opacity: 1, y: 0, transition: { type: "spring", bounce: 0.3 } },
};

ホバー時のカード拡大

<motion.div
  whileHover={{ scale: 1.03, boxShadow: "0 10px 30px rgba(0,0,0,0.15)" }}
  transition={{ type: "spring", stiffness: 400, damping: 25 }}
/>

ベストプラクティス

  1. バリアントを使用して親子アニメーションを連携させる
  2. スプリング物理で自然な動きを実現(線形イージングは避ける)
  3. layoutプロパティでレイアウト変更を自動アニメーション
  4. AnimatePresenceはexitアニメーションに必須
  5. layoutIdでルート間の共有要素トランジションを実現
  6. useScrollでスクロール連動アニメーション(パララックス、プログレスバー)
  7. whileHover/whileTapでインタラクティブなフィードバックを提供
  8. バリアントのtransition.staggerChildrenで子要素を段階的に表示
  9. アニメーションは控えめに — UIインタラクションでは0.2〜0.5秒の持続時間
  10. GPUアクセラレーション対応 — Motionはデフォルトでtransformを使用

MotionとGSAPの使い分け

MotionGSAP
フレームワークReactファーストフレームワーク非依存
スタイル宣言的(JSX props)命令的(関数呼び出し)
レイアウトアニメーション組み込み(マジック)手動
スクロールuseScrollフックScrollTriggerプラグイン
ジェスチャー組み込み(ドラッグ、ホバー、タップ)Draggableプラグイン
SVGモーフィング制限ありMorphSVGPlugin
バンドルサイズ約30KB約25KB(コア)

ソース

  • リポジトリ: github.com/motiondivision/motion
  • ドキュメント: motion.dev
  • サンプル: motion.dev/docs/react-quick-start

Individual skills in this repo

This repo contains 9 individual skills — each has its own dedicated page.

ever-just/agentskills

> Create animated logos, icons, and micro-interactions as lightweight Lottie JSON files. No After Effects needed — build animations entirely in code.

ever-just/agentskills

> A TypeScript library using generators to program animations with a real-time editor. Ideal for explainer videos, code walkthroughs, and educational content.

ever-just/agentskills

> Add animated subtitles and captions to Remotion videos from .SRT files. TikTok-style word-by-word highlights, karaoke effects, and more.

ever-just/agentskills

> Create videos programmatically using React components. The most mature framework for code-driven video production.

ever-just/agentskills

> Copy-paste video components for Remotion. Intros, text effects, transitions, and full scene templates. Like shadcn/ui but for video.

ever-just/agentskills

Extract actionable intelligence from video content across YouTube, Vimeo, and company websites. Video reveals what text sources cannot: facility scale, team composition, product demonstrations, signage, event attendance, and operational reality.

ever-just/agentskills

Optimize and embed an existing video as a fast, crisp, autoplaying hero/background/loop on a website. Use when adding or replacing a video on a marketing site and it is too heavy, will not autoplay (especially on mobile/Safari), shows a codec error, or looks soft — to transcode it to web-safe H.264 with the right pixel format, faststart, retina-aware sizing, and a poster frame, then embed and verify it actually plays. This is optimization + embedding of footage you already have, not creating/animating a video (for that use remotion/moviepy/motion-canvas). Use when the user says "add this video to the site", "the hero video is too big / won't play / isn't crisp", "replace the homepage video", or "make this loop on the landing page".

ever-just/agentskills

Full conversion audit for any homepage or landing page. Use when someone asks to "review my homepage," "audit my landing page," "why isn't my page converting," "check my website," or wants feedback on their marketing page. Requires URL or screenshot before proceeding.

ever-just/agentskills

Automatically fetch YouTube video transcripts, generate structured summaries, and send full transcripts to messaging platforms. Detects YouTube URLs and provides metadata, key insights, and downloadable transcripts.

関連スキル