Skip to content
Agents tracked: 440 Downloads (7d): 202M down 19.5% GitHub stars: 10.4M Releases (7d): 607 Agent status: 1 with issuesSince last limit reset: Claude 28d · Codex 0d Updated Oct 21, 2026

The animate prop in Framer Motion

The animate prop sets the values a motion component animates to. When those values change, for example from React state, the element animates to the new ones.

All Framer Motion examples Framer Motion: usage and stats

The animate prop in Framer Motion: screenshot of the example below running
The code below, running in Chromium on our server (Oct 12, 2026). Press Run to see it live and change it.

How it works

  1. Import from framer-motion. This example imports motion from framer-motion. The docs mostly show motion/react, and the Framer guide says to use the framer-motion import in its place. [1]
  2. Declare the target with animate. motion.div gets an animate object with x and rotate. Both values come from the on state, so clicking the button changes the target and the box animates to it. [2]
  3. Set timing with transition. transition={{ duration: 1 }} sets how long the animation lasts. initial={{ opacity: 0 }} sets the opacity the box starts from before it fades in. [1]

Run and edit it

It runs in your browser, in a sandboxed frame that cannot see this site; the packages load from esm.sh only after you press Run.

import { useState } from "react";
import { motion } from "framer-motion";

export default function App() {
  const [on, setOn] = useState(false);
  return (
    <div style={{ height: 340, padding: 30, fontFamily: "sans-serif" }}>
      <button onClick={() => setOn(!on)} style={{ padding: "8px 16px" }}>
        Toggle
      </button>
      <motion.div
        initial={{ opacity: 0 }}
        // Target values change with the `on` state
        animate={{ opacity: 1, x: on ? 300 : 0, rotate: on ? 90 : 0 }}
        transition={{ duration: 1 }}
        style={{
          width: 100,
          height: 100,
          marginTop: 60,
          borderRadius: 16,
          background: "#0368ff"
        }}
      />
      <p>x: {on ? 300 : 0}, rotate: {on ? 90 : 0}</p>
    </div>
  );
}
Ctrl/⌘ + Enter runs

Free for signed-in members, with a daily limit. Describe the change in plain words; the new code runs only in your browser.

Click Toggle to switch the box between its two animate targets. Code written by AgentGid [1].

Checked Oct 12, 2026: it starts without errors in Chromium with framer-motion 14.1.0, react 19.3.0, react-dom 19.3.0. Needs WebGL.

More Framer Motion examples

Drag with useTransform in Framer Motion useSpring in Framer Motion Shared layout animations with layoutId Hover and tap gestures in Framer Motion

Sources

  1. Docs: Motion x Framer integration guide
  2. llms.txt (docs index)

Explanations written by AgentGid from the official docs; the numbers in brackets point here. The code marked "written by AgentGid" is ours and free to copy.

Building something with Framer Motion? Ask AgentGid →