framer-motion vs react-spring vs react-motion vs react-transition-group
アニメーションライブラリ
framer-motionreact-springreact-motionreact-transition-group類似パッケージ:

アニメーションライブラリ

アニメーションライブラリは、ウェブアプリケーションやウェブサイトに視覚的な動きを追加するためのツールです。これらのライブラリは、要素のトランジション、フェードイン・フェードアウト、スライド、バウンスなど、さまざまなアニメーション効果を簡単に実装できるようにします。アニメーションは、ユーザーインターフェースをより魅力的にし、ユーザーの注意を引く手段として重要です。これらのライブラリは、CSSアニメーションやJavaScriptアニメーションを利用して、スムーズでインタラクティブな動きを実現します。

npmのダウンロードトレンド

3 年

GitHub Starsランキング

統計詳細

パッケージ
ダウンロード数
Stars
サイズ
Issues
公開日時
ライセンス
framer-motion33,472,16931,1514.63 MB2051日前MIT
react-spring1,010,75029,0568.36 kB1346ヶ月前MIT
react-motion732,49021,734-1938年前MIT
react-transition-group010,258244 kB258-BSD-3-Clause

機能比較: framer-motion vs react-spring vs react-motion vs react-transition-group

アニメーションの種類

  • framer-motion:

    framer-motionは、トランジション、ドラッグ、ホバー、クリックなど、さまざまなインタラクションに対応したアニメーションを提供します。特に、複雑なトランジションやインタラクティブなアニメーションを簡単に実装できるのが特徴です。

  • react-spring:

    react-springは、スプリング物理を利用したアニメーションを提供し、柔軟でリアルな動きを実現します。トランジション、ドラッグ、ホバーなど、さまざまなアニメーションスタイルに対応しており、カスタマイズが容易です。

  • react-motion:

    react-motionは、主に物理ベースのトランジションに焦点を当てています。アニメーションの動きが自然で滑らかになるように設計されており、特に位置やサイズの変化に対してリアルな動きを提供します。

  • react-transition-group:

    react-transition-groupは、要素のマウントやアンマウントに伴うトランジションを管理します。フェードイン・フェードアウト、スライドイン・スライドアウトなど、シンプルなトランジションを実装するのに適しています。

カスタマイズ性

  • framer-motion:

    framer-motionは、アニメーションのプロパティを細かく設定できるため、デザインに合わせたカスタマイズが容易です。特に、インタラクションに応じた動きを簡単に設定できるのが特徴です。

  • react-spring:

    react-springは、スプリングの設定(バネの強さやダンピングなど)を細かく調整できるため、非常に高いカスタマイズ性を持っています。デザインに合わせたリアルな動きを作りたい場合に最適です。

  • react-motion:

    react-motionは、物理法則に基づいたアニメーションを提供するため、動きのカスタマイズは限られていますが、自然な動きを重視するデザインには適しています。

  • react-transition-group:

    react-transition-groupは、トランジションのクラス名やスタイルをカスタマイズできるため、シンプルなトランジションをデザインに合わせて調整することができます。

学習曲線

  • framer-motion:

    framer-motionは、直感的なAPIと豊富なドキュメントが提供されているため、比較的短時間で習得できます。特に、デザインに特化した機能が多いため、デザイナーにも使いやすいです。

  • react-spring:

    react-springは、スプリング物理に基づいているため、最初は理解に時間がかかるかもしれませんが、柔軟性とカスタマイズ性が高いため、一度習得すれば多くの場面で活用できます。

  • react-motion:

    react-motionは、物理ベースのアニメーションを理解する必要があるため、少し学習が必要ですが、自然な動きを実現するための概念はシンプルです。

  • react-transition-group:

    react-transition-groupは、トランジションの概念がシンプルで、比較的簡単に習得できます。特に、既存のCSSトランジションを利用する場合は、すぐに使い始めることができます。

パフォーマンス

  • react-spring:

    react-springは、スプリング物理を使用しているため、特に多くのアニメーションを同時に実行する場合は注意が必要ですが、最適化が行われているため、一般的な使用では問題ありません。

  • react-motion:

    react-motionは、物理ベースのアニメーションを使用しているため、計算コストがかかる場合がありますが、適切に使用すればパフォーマンスへの影響は最小限です。

  • react-transition-group:

    react-transition-groupは、CSSトランジションやアニメーションを利用するため、ブラウザの最適化を活かすことができ、パフォーマンスは良好です。ただし、アニメーションの数が多くなると、注意が必要です。

コード例

  • framer-motion:

    framer-motionを使用したアニメーションの例

    import { motion } from 'framer-motion';
    
    function Example() {
      return (
        <motion.div
          initial={{ opacity: 0 }}
          animate={{ opacity: 1 }}
          exit={{ opacity: 0 }}
          transition={{ duration: 0.5 }}
        >
          フェードイン・フェードアウト
        </motion.div>
      );
    }
    
  • react-spring:

    react-springを使用したアニメーションの例

    import { useSpring, animated } from 'react-spring';
    
    function Example() {
      const props = useSpring({ to: { opacity: 1 }, from: { opacity: 0 } });
      return <animated.div style={props}>スプリングアニメーション</animated.div>;
    }
    
  • react-motion:

    react-motionを使用したアニメーションの例

    import { Motion, spring } from 'react-motion';
    
    function Example() {
      return (
        <Motion defaultStyle={{ x: 0 }} style={{ x: spring(100) }}>
          {style => <div style={{ transform: 
    `translateX(${style.x}px)` }}>スプリングアニメーション</div>}
        </Motion>
      );
    }
    
  • react-transition-group:

    react-transition-groupを使用したアニメーションの例

    import { CSSTransition, TransitionGroup } from 'react-transition-group';
    
    function Example() {
      return (
        <TransitionGroup>
          <CSSTransition classNames="fade" timeout={500}>
            <div>フェードアニメーション</div>
          </CSSTransition>
        </TransitionGroup>
      );
    }
    

選び方: framer-motion vs react-spring vs react-motion vs react-transition-group

  • framer-motion:

    framer-motionは、特にReactアプリケーション向けに設計されたアニメーションライブラリで、インタラクティブでダイナミックなアニメーションを簡単に作成できます。複雑なアニメーションを直感的に作成できるため、デザインにこだわるプロジェクトに最適です。

  • react-spring:

    react-springは、スプリング物理に基づいたアニメーションを提供するライブラリで、柔軟性が高く、リアルな動きを簡単に作成できます。アニメーションのカスタマイズ性が高く、デザインに合わせた動きを作りたい場合におすすめです。

  • react-motion:

    react-motionは、物理ベースのアニメーションを提供するライブラリで、自然な動きを実現します。アニメーションの動きに物理法則を取り入れたい場合に適しています。

  • react-transition-group:

    react-transition-groupは、トランジションとアニメーションを管理するためのコンポーネントを提供するライブラリで、特に要素の出入りに焦点を当てています。要素のマウントやアンマウント時にアニメーションを追加したい場合に適しています。

framer-motion のREADME

Motion logo
Motion for React

An open source animation library
for React

npm version npm downloads per month jsDelivr hits (npm) NPM License

npm install motion

Table of Contents

  1. Why Motion?
  2. 🍦 Platforms
  3. 🎓 Examples
  4. ⚡️ Motion+
  5. 👩🏻‍⚖️ License
  6. 💎 Contribute
  7. ✨ Sponsors

Why Motion?

  • Simple API: First-class React, JavaScript, and Vue packages.
  • Hybrid engine: Power of JavaScript combined with native browser APIs for 120fps, GPU-accelerated animations.
  • Production-ready: TypeScript, extensive test suite, tree-shakable, tiny footprint. Batteries included: Gestures, springs, layout transitions, scroll-linked effects, timelines.

🍦 Platforms

Motion is available for React, JavaScript and Vue.

React
import { motion } from "motion/react"

function Component() {
    return <motion.div animate={{ x: 100 }} />
}

Get started with Motion for React.

JavaScript
import { animate } from "motion"

animate("#box", { x: 100 })

Get started with JavaScript.

Vue
<script>
    import { motion } from "motion-v"
</script>

<template> <motion.div :animate={{ x: 100 }} /> </template>

Get started with Motion for Vue.

🎓 Examples

Browse 100+ free and 180+ premium Motion Examples, with copy-paste code that'll level-up your animations whether you're a beginner or an expert.

⚡️ Motion+

A one-time payment, lifetime-updates membership:

  • 180+ premium examples
  • Premium APIs like Cursor and Ticker
  • Visual editing for VS Code (alpha)
  • Private Discord
  • Early access content

Get Motion+

👩🏻‍⚖️ License

  • Motion is MIT licensed.

💎 Contribute

✨ Sponsors

Motion is sustainable thanks to the kind support of its sponsors.

Become a sponsor

Partners

Motion powers the animations for all websites built with Framer, the web builder for creative pros. The Motion website itself is built on Framer, for its delightful canvas-based editing and powerful CMS features.

Framer

Motion drives the animations on the Cursor homepage, and is working with Cursor to bring powerful AI workflows to the Motion examples and docs.

Cursor

Platinum

Linear Figma Sanity Sanity Clerk Greptile

Gold

LottieFiles Mintlify

Silver

Liveblocks Frontend.fyi Firecrawl Puzzmo Bolt.new

Personal