Skip to content

Motion Grid Notes

MIT-licensed animation library for React and JavaScript (formerly Framer Motion), offering a 3.3 kB `motion/mini` WAAPI build as well as layout, gesture and spring animations.

Grid NotesVersion 14.7.1MotionChecked 2026-11-12
Setup & agent config

Install and prerequisites

What your agent should install or configure before writing code with this pack.
Terminal
npm install motion
Packages:motion

In React 18/19, import from motion/react (or motion/mini for tiny WAAPI animations), never from the legacy framer-motion package.

Framework setup

Production-ready wiring for React 19, Next.js App Router and Tailwind CSS v4.

Lightweight WAAPI animations with motion/mini (3.3 kB)

Use animate from motion/mini when you only need hardware-accelerated opacity or transform transitions without pulling in the 33 kB full runtime.

components/fade-presence.tsx
"use client";

import { useEffect, useRef } from "react";
import { animate } from "motion/mini";

export function FadeIn({ children }: { children: React.ReactNode }) {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    if (!ref.current) return;
    const controls = animate(
      ref.current,
      { opacity: [0, 1], transform: ["translateY(4px)", "translateY(0px)"] },
      { duration: 0.2, easing: [0.22, 1, 0.36, 1] },
    );
    return () => controls.cancel();
  }, []);

  return <div ref={ref}>{children}</div>;
}

Tree-shaken React components with LazyMotion + m

When you need AnimatePresence, variants or gestures, pair LazyMotion (strict) with m from motion/react-m and MotionConfig reducedMotion="user".

components/motion-provider.tsx
"use client";

import { LazyMotion, MotionConfig, domAnimation } from "motion/react";
import * as m from "motion/react-m";

export function MotionProvider({ children }: { children: React.ReactNode }) {
  return (
    <LazyMotion features={domAnimation} strict>
      <MotionConfig reducedMotion="user">{children}</MotionConfig>
    </LazyMotion>
  );
}

export function Card({ children }: { children: React.ReactNode }) {
  return <m.div initial={{ opacity: 0, y: 8 }} animate={{ opacity: 1, y: 0 }}>{children}</m.div>;
}

Gotchas for agents

Real-world traps — version mismatches, licence boundaries, main-thread stalls and CSS layer rules — that trip AI agents up.
  1. Pass both keyframes to motion/mini animate()

    motion/mini runs on the Web Animations API. Passing a single target value like { opacity: 0 } forces a synchronous getComputedStyle() read on the main thread; pass explicit [from, to] arrays ({ opacity: [1, 0] }) when the starting state is known.

  2. motion/mini uses transform strings, not shorthand props

    Unlike full <motion.div y={8}>, motion/mini's animate() expects standard CSS properties such as transform: ["translateY(8px)", "translateY(0px)"].

  3. Physics spring options override duration and bounce

    In Motion's spring generator (type: "spring"), specifying stiffness, damping or mass overrides duration and bounce. Default physics values are stiffness: 100, damping: 10, mass: 1 (damping ratio damping / (2 * Math.sqrt(stiffness * mass))).

  4. Bundle cost of full motion vs LazyMotion vs mini

    motion/mini is 3.3 kB gzip; LazyMotion + domAnimation is about 32.9 kB gzip (domMax adds layout and drag). Never import the full motion object from motion/react when LazyMotion strict is used.

Accessibility and reduced motion

How to keep animations and interactive components accessible across keyboard, screen readers and prefers-reduced-motion.

Reduced motion

Wrap full Motion trees in <MotionConfig reducedMotion="user">: Motion disables transform and layout animations while preserving opacity and colour transitions. For motion/mini, check window.matchMedia('(prefers-reduced-motion: reduce)').matches and omit transform keyframes.

Keyboard and screen readers

When animating tab panels or step swaps, avoid holding the incoming panel behind an AnimatePresence mode="wait" exit delay if focus needs to move to the new heading immediately.