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

Kyle Gill
InstructorKyle Gill
Share this video with your friends

Social Share Links

Send Tweet
Published 5 years ago
Updated 3 years 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.

egghead
egghead
~ a minute ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today