Motion (Animation Library)

12.38.0 · active · verified Sun Apr 19

Motion, formerly known as Framer Motion, is a robust and highly performant open-source animation library designed for modern web development, offering first-class support for React, vanilla JavaScript, and Vue (via the separate `motion-v` package). As of version 12.38.0, it provides a simple yet powerful API for creating 120fps, GPU-accelerated animations using a hybrid engine that intelligently combines JavaScript capabilities with native browser APIs. The library maintains an active and frequent release cadence, with updates often published weekly or bi-weekly. Key differentiators include its comprehensive suite of "batteries-included" features, such as declarative gestures (drag, tap, hover), spring physics, advanced layout transitions for shared elements, scroll-linked effects, and complex timeline orchestrations. Motion is production-ready, featuring TypeScript support, tree-shakability, a tiny footprint, and an extensive test suite, making it a reliable choice for building fluid and interactive user interfaces across various platforms.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates a basic animated React component using Motion, showcasing initial and animate props, custom transitions, and interactive `whileHover`/`whileTap` gestures.

import React from 'react';
import { motion } from 'motion/react';

function AnimatedBox() {
  return (
    <motion.div
      initial={{ opacity: 0, x: -100 }}
      animate={{ opacity: 1, x: 0 }}
      transition={{
        duration: 0.8,
        delay: 0.2,
        ease: [0, 0.71, 0.2, 1.01]
      }}
      style={{
        width: '100px',
        height: '100px',
        backgroundColor: '#61dafb',
        borderRadius: '10px',
        display: 'flex',
        justifyContent: 'center',
        alignItems: 'center',
        fontSize: '1.2rem',
        color: 'white',
        cursor: 'pointer'
      }}
      whileHover={{ scale: 1.1, backgroundColor: '#282c34' }}
      whileTap={{ scale: 0.9 }}
    >
      Hello Motion!
    </motion.div>
  );
}

export default AnimatedBox;

view raw JSON →