Animate a React component's position with the animate prop from Framer Motion

Kyle Gill
InstructorKyle Gill

Share this video with your friends

Send Tweet
Published 2 years ago
Updated 10 months ago

Learn how to apply simple animations with default transitions generated by Framer Motion to any React component.

The animate prop can animate location, scale, and a host of other attributes, and the transition prop can override the generated defaults.

Instructor: [00:00] Install framer-motion to start using it in a project that uses React. import { motion } from "framer-motion" then replace the tag with its motion components from the library. All HTML and SPGL elements are supported.

[00:19] All motion components can be animated using the animate prop. The animate prop can take an object defining what the component will animate too, like XY coordinates scale and more. This component will animate to an X location 100 pixels away.

[00:40] You can pass an object with transition prop to override the generated transitions provided by framer-motion to modify characteristics like when the animations run or for how long. In this case, for a duration of 2.5 seconds.