Skip to main content
VibeStacks

Loading the search index…

EntryTop pick

Motion

The most used animation library in React. Write enter, exit, layout, and gesture animations as declarative props.

Last reviewed
Applies to
Motion 14
Website
motion.dev

Good for

  • Elements entering and leaving, list reordering, layout changes, drag and gestures
  • React projects that want UI with good feel without hand-writing timelines and interpolation
  • Projects that need to handle the reduced-motion preference in one place

Not for

  • Simple hover or color transitions (one line of CSS transition is enough)
  • Complex timeline choreography and scroll storytelling (consider a dedicated timeline library)

Motion (formerly Framer Motion) lets you write animation as component props: initial is where it starts, animate is where it ends, and exit is how it leaves. It handles interpolation, spring physics, and interruption; you only describe states.

Why it is our top pick

  • Declarative, so AI gets it right. An animation is a few props, so the AI rarely makes mistakes, and it reads far better than hand-written requestAnimationFrame.
  • Exit and layout animations. AnimatePresence lets elements finish an exit animation before unmounting, and the layout prop smoothly animates position and size changes. Both are hard to do well in CSS.
  • Sensible physics by default. Spring animations can be interrupted mid-flight without jumping, which feels more natural.
  • Respects user settings. MotionConfig with reducedMotion="user" follows the system's reduced-motion preference.

Getting started

pnpm add motion
import { motion } from 'motion/react';

export function Toast({ message }: { message: string }) {
  return (
    <motion.div initial={{ opacity: 0, y: 8 }} animate={{ opacity: 1, y: 0 }} exit={{ opacity: 0 }}>
      {message}
    </motion.div>
  );
}

Trade-offs to know

More animation is not better. Give the AI rules (see the souvenir): animate only transform and opacity, keep durations short, and give every animation a purpose.

Souvenir

Take it home to your AI

Drop this AGENTS.md into your project, or paste it straight to your AI coding assistant.

AGENTS.md
# AGENTS.md (motion section)

## Tools
- Use Motion (`import { motion } from 'motion/react'`) for enter / exit / layout / gesture animations.
- Use CSS transitions for simple hover and color changes; do not pull in Motion for those.

## Rules
- Animate only `transform` (translate, scale, rotate) and `opacity`; never width, height, margins, or `top/left`.
- UI feedback animations last 150–300ms; never make users wait for an animation before they can act.
- Every animation needs a purpose: explain a state change, guide attention, or show spatial relationships. When unsure, leave it out.
- Wrap the app root in `<MotionConfig reducedMotion="user">` to follow the system reduced-motion preference.
- Put exiting list items inside `<AnimatePresence>` and give each a stable `key`.
  • Article

    Functional and display components

    Functional components answer "does it work?" (forms, dialogs, menus); display components answer "does it look good?" (3D, motion, visual style). You choose them in completely different ways.

  • EntryTop pick

    three.js

    The de facto standard for 3D on the web. In React, pair it with React Three Fiber and write scenes as components.

  • EntryTop pick

    shadcn/ui

    Not a component library but component source you copy into your repository. Accessibility comes from proven primitives; the look is yours to change with Tailwind.