Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


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

    Kyle GillKyle Gill

    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.



    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson




    Instructor: 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.

    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.

    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.