Get started with Motion for React
Presented by
Clerk
Motion for React (previously Framer Motion) is a React animation library for building smooth, production-grade UI animations. You can start with simple prop-based animations before growing to layout, gesture and scroll animations.
Motion's unique hybrid engine delivers 120fps animations by combining native browser APIs like Web Animations API and ScrollTimeline with the flexibility of JavaScript. It's also trusted by companies like Framer and Figma to power their amazing no-code animations and gestures.
In this guide, we'll learn why and when you should use Motion, how to install it, and give you an overview of its main features.
Why Motion for React?
React gives you the power to build dynamic user interfaces, but orchestrating complex, performant animations can be a challenge. Motion is a production-ready React animation library designed to solve this problem, making it simple to create everything from beautiful micro-interactions to complex, gesture-driven animations.
import { motion } from "motion/react" function Component() { return <motion.button animate={{ opacity: 1 }} /> }
Key advantages
Here’s when it’s the right choice for your project.
Built for React. While other animation libraries like GSAP are messy to integrate with React, Motion's declarative API is a natural fit. Animations can be linked directly to state and props.
Hardware-acceleration. Motion leverages the same high-performance browser animations as CSS, ensuring your UIs stay smooth and snappy. 120fps animations with a much simpler and more expressive API.
Animate anything. CSS has hard limits. Values you can't animate, keyframes you can't interrupt, staggers that must be hardcoded. Motion provides a single, consistent API that scales from simple to complex.
App-like gestures. Standard CSS
:hoverevents are unreliable on touch devices. Motion provides robust, cross-device gesture recognisers for tap, drag, and hover that feel native and intuitive on any device.Tree-shakable. Motion is written according to modern JS standards, so you only use what you import. Our tiny
useAnimatefunction is less than 3kb!
When is CSS a better choice?
For simple, self-contained effects (like a color change on hover) a standard CSS transition is a lightweight solution. The strength of Motion is that it can do these simple kinds of animations but also scale to anything you can imagine. All with the same easy to write and maintain API.
Install
Motion is available via npm:
npm install motion
Features can now be imported via "motion/react":
import { motion } from "motion/react"
Prefer to install via CDN, or looking for framework-specific instructions? Check out our full installation guide.
Your first animation
The <motion /> component is the core API in Motion for React. It renders any HTML or SVG element with extra animation and gesture abilities.
<motion.ul animate={{ rotate: 360 }} />
When values in animate change, the component will animate. Motion has intuitive defaults, but animations can of course be configured via the transition prop.
<motion.div animate={{ scale: 2, transition: { duration: 2 } }} />
Learn more about React animation
If you're the kind of developer who learns better by doing, check out our library of Basics examples. Each comes complete with a live demo and copy/paste source code.
Enter animation
When a component enters the page, it will automatically animate to the values defined in the animate prop.
You can provide values to animate from via the initial prop (otherwise these will be read from the DOM).
<motion.button initial={{ scale: 0 }} animate={{ scale: 1 }} />
Or disable this initial animation entirely by setting initial to false.
<motion.button initial={false} animate={{ scale: 1 }} />
Hover & tap animation
<motion /> extends React's event system with powerful gesture animations. It currently supports hover, tap, focus, and drag.
<motion.button whileHover={{ scale: 1.1 }} whileTap={{ scale: 0.95 }} onHoverStart={() => console.log('hover started!')} />
Motion's gestures are designed to feel better than using CSS or JavaScript events alone.
Scroll animation
Motion supports both types of scroll animations: Scroll-triggered and scroll-linked.
To trigger an animation on scroll, the whileInView prop defines a state to animate to/from when an element enters/leaves the viewport:
<motion.div initial={{ backgroundColor: "rgb(0, 255, 0)", opacity: 0 }} whileInView={{ backgroundColor: "rgb(255, 0, 0)", opacity: 1 }} />
Whereas to link a value directly to scroll position, it's possible to use MotionValues via useScroll.
const { scrollYProgress } = useScroll() return <motion.div style={{ scaleX: scrollYProgress }} />
Layout animation
Motion's layout animation engine detects layout changes (size, position, reorder) and smoothly animates between states using transforms. Unlike basic "FLIP" implementations, it does so while correcting for scale-distortion.
It's as easy as applying the layout prop.
<motion.div layout />
Or to animate between completely different elements, a layoutId:
<motion.div layoutId="underline" />
Exit animations
By wrapping motion components with <AnimatePresence> we gain access to exit animations. This allows us to animate elements as they're removed from the DOM.
<AnimatePresence> {show ? <motion.div key="box" exit={{ opacity: 0 }} /> : null} </AnimatePresence>
SVG animations
Motion has full support for SVG animations, including support for animating viewBox and special values for simple path drawing effects.
<motion.circle animate={{ pathLength: 1 }} />
Development tools
Motion Studio provides AI and visual animation editing directly inside your code editor. Enhance your workflow tools with an AI-searchable examples database, a CSS and Motion transition editor, performance audit skill, and more.
Install Motion Studio
One-click install for Cursor:
Motion Studio is also compatible with VS Code, Google Antigravity and more. See full installation guide.
Learn next
That's a very quick overview of Motion for React's basic features. But there's a lot more to learn!
Next, we recommend starting with the React animation guide. There, you'll learn more about the different types of animations you can build with this React animation library.
Or, you can learn by doing, diving straight into our collection of examples. Each comes complete with full source code that you can copy-paste into your project.
Motion for React (previously Framer Motion) is a React animation library for building smooth, production-grade UI animations. You can start with simple prop-based animations before growing to layout, gesture and scroll animations.
Motion's unique hybrid engine delivers 120fps animations by combining native browser APIs like Web Animations API and ScrollTimeline with the flexibility of JavaScript. It's also trusted by companies like Framer and Figma to power their amazing no-code animations and gestures.
In this guide, we'll learn why and when you should use Motion, how to install it, and give you an overview of its main features.
Why Motion for React?
React gives you the power to build dynamic user interfaces, but orchestrating complex, performant animations can be a challenge. Motion is a production-ready React animation library designed to solve this problem, making it simple to create everything from beautiful micro-interactions to complex, gesture-driven animations.
import { motion } from "motion/react" function Component() { return <motion.button animate={{ opacity: 1 }} /> }
Key advantages
Here’s when it’s the right choice for your project.
Built for React. While other animation libraries like GSAP are messy to integrate with React, Motion's declarative API is a natural fit. Animations can be linked directly to state and props.
Hardware-acceleration. Motion leverages the same high-performance browser animations as CSS, ensuring your UIs stay smooth and snappy. 120fps animations with a much simpler and more expressive API.
Animate anything. CSS has hard limits. Values you can't animate, keyframes you can't interrupt, staggers that must be hardcoded. Motion provides a single, consistent API that scales from simple to complex.
App-like gestures. Standard CSS
:hoverevents are unreliable on touch devices. Motion provides robust, cross-device gesture recognisers for tap, drag, and hover that feel native and intuitive on any device.Tree-shakable. Motion is written according to modern JS standards, so you only use what you import. Our tiny
useAnimatefunction is less than 3kb!
When is CSS a better choice?
For simple, self-contained effects (like a color change on hover) a standard CSS transition is a lightweight solution. The strength of Motion is that it can do these simple kinds of animations but also scale to anything you can imagine. All with the same easy to write and maintain API.
Install
Motion is available via npm:
npm install motion
Features can now be imported via "motion/react":
import { motion } from "motion/react"
Prefer to install via CDN, or looking for framework-specific instructions? Check out our full installation guide.
Your first animation
The <motion /> component is the core API in Motion for React. It renders any HTML or SVG element with extra animation and gesture abilities.
<motion.ul animate={{ rotate: 360 }} />
When values in animate change, the component will animate. Motion has intuitive defaults, but animations can of course be configured via the transition prop.
<motion.div animate={{ scale: 2, transition: { duration: 2 } }} />
Learn more about React animation
If you're the kind of developer who learns better by doing, check out our library of Basics examples. Each comes complete with a live demo and copy/paste source code.
Enter animation
When a component enters the page, it will automatically animate to the values defined in the animate prop.
You can provide values to animate from via the initial prop (otherwise these will be read from the DOM).
<motion.button initial={{ scale: 0 }} animate={{ scale: 1 }} />
Or disable this initial animation entirely by setting initial to false.
<motion.button initial={false} animate={{ scale: 1 }} />
Hover & tap animation
<motion /> extends React's event system with powerful gesture animations. It currently supports hover, tap, focus, and drag.
<motion.button whileHover={{ scale: 1.1 }} whileTap={{ scale: 0.95 }} onHoverStart={() => console.log('hover started!')} />
Motion's gestures are designed to feel better than using CSS or JavaScript events alone.
Scroll animation
Motion supports both types of scroll animations: Scroll-triggered and scroll-linked.
To trigger an animation on scroll, the whileInView prop defines a state to animate to/from when an element enters/leaves the viewport:
<motion.div initial={{ backgroundColor: "rgb(0, 255, 0)", opacity: 0 }} whileInView={{ backgroundColor: "rgb(255, 0, 0)", opacity: 1 }} />
Whereas to link a value directly to scroll position, it's possible to use MotionValues via useScroll.
const { scrollYProgress } = useScroll() return <motion.div style={{ scaleX: scrollYProgress }} />
Layout animation
Motion's layout animation engine detects layout changes (size, position, reorder) and smoothly animates between states using transforms. Unlike basic "FLIP" implementations, it does so while correcting for scale-distortion.
It's as easy as applying the layout prop.
<motion.div layout />
Or to animate between completely different elements, a layoutId:
<motion.div layoutId="underline" />
Exit animations
By wrapping motion components with <AnimatePresence> we gain access to exit animations. This allows us to animate elements as they're removed from the DOM.
<AnimatePresence> {show ? <motion.div key="box" exit={{ opacity: 0 }} /> : null} </AnimatePresence>
SVG animations
Motion has full support for SVG animations, including support for animating viewBox and special values for simple path drawing effects.
<motion.circle animate={{ pathLength: 1 }} />
Development tools
Motion Studio provides AI and visual animation editing directly inside your code editor. Enhance your workflow tools with an AI-searchable examples database, a CSS and Motion transition editor, performance audit skill, and more.
Install Motion Studio
One-click install for Cursor:
Motion Studio is also compatible with VS Code, Google Antigravity and more. See full installation guide.
Learn next
That's a very quick overview of Motion for React's basic features. But there's a lot more to learn!
Next, we recommend starting with the React animation guide. There, you'll learn more about the different types of animations you can build with this React animation library.
Or, you can learn by doing, diving straight into our collection of examples. Each comes complete with full source code that you can copy-paste into your project.
Motion for React (previously Framer Motion) is a React animation library for building smooth, production-grade UI animations. You can start with simple prop-based animations before growing to layout, gesture and scroll animations.
Motion's unique hybrid engine delivers 120fps animations by combining native browser APIs like Web Animations API and ScrollTimeline with the flexibility of JavaScript. It's also trusted by companies like Framer and Figma to power their amazing no-code animations and gestures.
In this guide, we'll learn why and when you should use Motion, how to install it, and give you an overview of its main features.
Why Motion for React?
React gives you the power to build dynamic user interfaces, but orchestrating complex, performant animations can be a challenge. Motion is a production-ready React animation library designed to solve this problem, making it simple to create everything from beautiful micro-interactions to complex, gesture-driven animations.
import { motion } from "motion/react" function Component() { return <motion.button animate={{ opacity: 1 }} /> }
Key advantages
Here’s when it’s the right choice for your project.
Built for React. While other animation libraries like GSAP are messy to integrate with React, Motion's declarative API is a natural fit. Animations can be linked directly to state and props.
Hardware-acceleration. Motion leverages the same high-performance browser animations as CSS, ensuring your UIs stay smooth and snappy. 120fps animations with a much simpler and more expressive API.
Animate anything. CSS has hard limits. Values you can't animate, keyframes you can't interrupt, staggers that must be hardcoded. Motion provides a single, consistent API that scales from simple to complex.
App-like gestures. Standard CSS
:hoverevents are unreliable on touch devices. Motion provides robust, cross-device gesture recognisers for tap, drag, and hover that feel native and intuitive on any device.Tree-shakable. Motion is written according to modern JS standards, so you only use what you import. Our tiny
useAnimatefunction is less than 3kb!
When is CSS a better choice?
For simple, self-contained effects (like a color change on hover) a standard CSS transition is a lightweight solution. The strength of Motion is that it can do these simple kinds of animations but also scale to anything you can imagine. All with the same easy to write and maintain API.
Install
Motion is available via npm:
npm install motion
Features can now be imported via "motion/react":
import { motion } from "motion/react"
Prefer to install via CDN, or looking for framework-specific instructions? Check out our full installation guide.
Your first animation
The <motion /> component is the core API in Motion for React. It renders any HTML or SVG element with extra animation and gesture abilities.
<motion.ul animate={{ rotate: 360 }} />
When values in animate change, the component will animate. Motion has intuitive defaults, but animations can of course be configured via the transition prop.
<motion.div animate={{ scale: 2, transition: { duration: 2 } }} />
Learn more about React animation
If you're the kind of developer who learns better by doing, check out our library of Basics examples. Each comes complete with a live demo and copy/paste source code.
Enter animation
When a component enters the page, it will automatically animate to the values defined in the animate prop.
You can provide values to animate from via the initial prop (otherwise these will be read from the DOM).
<motion.button initial={{ scale: 0 }} animate={{ scale: 1 }} />
Or disable this initial animation entirely by setting initial to false.
<motion.button initial={false} animate={{ scale: 1 }} />
Hover & tap animation
<motion /> extends React's event system with powerful gesture animations. It currently supports hover, tap, focus, and drag.
<motion.button whileHover={{ scale: 1.1 }} whileTap={{ scale: 0.95 }} onHoverStart={() => console.log('hover started!')} />
Motion's gestures are designed to feel better than using CSS or JavaScript events alone.
Scroll animation
Motion supports both types of scroll animations: Scroll-triggered and scroll-linked.
To trigger an animation on scroll, the whileInView prop defines a state to animate to/from when an element enters/leaves the viewport:
<motion.div initial={{ backgroundColor: "rgb(0, 255, 0)", opacity: 0 }} whileInView={{ backgroundColor: "rgb(255, 0, 0)", opacity: 1 }} />
Whereas to link a value directly to scroll position, it's possible to use MotionValues via useScroll.
const { scrollYProgress } = useScroll() return <motion.div style={{ scaleX: scrollYProgress }} />
Layout animation
Motion's layout animation engine detects layout changes (size, position, reorder) and smoothly animates between states using transforms. Unlike basic "FLIP" implementations, it does so while correcting for scale-distortion.
It's as easy as applying the layout prop.
<motion.div layout />
Or to animate between completely different elements, a layoutId:
<motion.div layoutId="underline" />
Exit animations
By wrapping motion components with <AnimatePresence> we gain access to exit animations. This allows us to animate elements as they're removed from the DOM.
<AnimatePresence> {show ? <motion.div key="box" exit={{ opacity: 0 }} /> : null} </AnimatePresence>
SVG animations
Motion has full support for SVG animations, including support for animating viewBox and special values for simple path drawing effects.
<motion.circle animate={{ pathLength: 1 }} />
Development tools
Motion Studio provides AI and visual animation editing directly inside your code editor. Enhance your workflow tools with an AI-searchable examples database, a CSS and Motion transition editor, performance audit skill, and more.
Install Motion Studio
One-click install for Cursor:
Motion Studio is also compatible with VS Code, Google Antigravity and more. See full installation guide.
Learn next
That's a very quick overview of Motion for React's basic features. But there's a lot more to learn!
Next, we recommend starting with the React animation guide. There, you'll learn more about the different types of animations you can build with this React animation library.
Or, you can learn by doing, diving straight into our collection of examples. Each comes complete with full source code that you can copy-paste into your project.

