{"id":1086,"date":"2026-07-02T06:57:04","date_gmt":"2026-07-01T23:57:04","guid":{"rendered":"https:\/\/sumberlaba.com\/index.php\/2026\/07\/02\/mastering-framer-motion-the-ultimate-guide-to-animating-react-apps\/"},"modified":"2026-07-02T06:57:04","modified_gmt":"2026-07-01T23:57:04","slug":"mastering-framer-motion-the-ultimate-guide-to-animating-react-apps","status":"publish","type":"post","link":"https:\/\/sumberlaba.com\/index.php\/2026\/07\/02\/mastering-framer-motion-the-ultimate-guide-to-animating-react-apps\/","title":{"rendered":"Mastering Framer Motion: The Ultimate Guide to Animating React Apps"},"content":{"rendered":"<h1>Mastering Framer Motion: The Ultimate Guide to Animating React Apps<\/h1>\n<p>Framer Motion is a production-ready motion library for React that makes creating fluid, declarative animations remarkably simple. Whether you&#8217;re building a landing page with subtle micro-interactions or a complex UI with shared layout animations and gesture-driven transitions, Framer Motion provides a powerful yet intuitive API. Unlike CSS animations or older JavaScript animation libraries, Framer Motion integrates seamlessly with React&#8217;s component model, allowing you to animate props, variants, and even layout changes without touching the DOM directly. In this comprehensive tutorial, we will cover everything you need to get started, from installation to advanced patterns like AnimatePresence, layout animations, and scroll-triggered effects. By the end of this guide, you will be able to add professional-grade animations to any React project with confidence.<\/p>\n<p>The library was built by the team behind Framer, a design tool for prototyping, and it has become the go-to solution for React animation. Its core philosophy is <em>declarative animation<\/em>\u2014you define what the animation should look like (e.g., start and end states) and Framer Motion handles the interpolation, easing, and performance optimizations automatically. Under the hood, it leverages the Web Animations API and requestAnimationFrame for smooth 60fps animations, but you never need to worry about the implementation details. Instead, you work with familiar React concepts like <code>motion<\/code> components, <code>animate<\/code> props, and <code>variants<\/code>. This guide assumes you have a basic understanding of React (components, state, props, hooks) but no prior experience with animation libraries. Each step will be explained thoroughly with code examples, best practices, and common pitfalls to avoid.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/via.placeholder.com\/800x600\/4a90d9\/ffffff?text=how%20to%20use%20Framer%20Motion%20for%20animations\" alt=\"Article illustration\" style=\"display:block;margin:20px auto;max-width:100%;height:auto;border-radius:8px;\" \/><\/p>\n<h2>Setting Up Framer Motion in Your Project<\/h2>\n<p>Before we can start animating, we need to install the library. Framer Motion is available as an npm package and works with any React project built with Create React App, Vite, Next.js, or even a custom Webpack setup. The installation process is straightforward: open your terminal in the project root directory and run <code>npm install framer-motion<\/code> or <code>yarn add framer-motion<\/code>. Once installed, you can import the necessary components and hooks. The two primary exports you&#8217;ll use are <code>motion<\/code> (a factory for creating animated HTML\/SVG elements) and <code>AnimatePresence<\/code> (for entering and exiting animations). For more advanced use cases, you may also import <code>useAnimation<\/code>, <code>useInView<\/code>, <code>useCycle<\/code>, and other utilities. It&#8217;s important to note that Framer Motion is tree-shakable, so you only bundle the parts you actually use. For example, if you only need basic animations, importing <code>motion<\/code> is sufficient; you don&#8217;t need to import the entire library. In this tutorial, we&#8217;ll assume you have React 16.8 or later (hooks support) and a modern browser. After installation, create a new component file (e.g., <code>AnimationDemo.jsx<\/code>) and start by adding the import statement: <code>import { motion } from 'framer-motion';<\/code>. Now you&#8217;re ready to build your first animation.<\/p>\n<h2>Step-by-Step Guide to Using Framer Motion<\/h2>\n<h3>Step 1: Creating Your First Motion Component and Applying the <code>animate<\/code> Prop<\/h3>\n<p>The most fundamental concept in Framer Motion is the <code>motion<\/code> component. Instead of using standard HTML elements like <code>&lt;div&gt;<\/code> or <code>&lt;span&gt;<\/code>, you replace them with <code>motion.div<\/code> or <code>motion.span<\/code>. These components behave exactly like their native counterparts, but they expose animation-related props. The simplest animation is achieved by using the <code>animate<\/code> prop, which defines the final state of the element after the animation. For example, to make a box move from its current position to 100 pixels to the right and simultaneously change its opacity from 0 to 1, you would write: <code>&lt;motion.div animate={{ x: 100, opacity: 1 }} \/&gt;<\/code>. By default, the element will animate from its initial CSS state (if no <code>initial<\/code> prop is set) to the <code>animate<\/code> state. The transition between these states is automatically tweened using default easing (ease-in-out) and a duration of 0.3 seconds. However, you can customize the timing, easing, and delay using a <code>transition<\/code> prop. For instance, <code>&lt;motion.div animate={{ x: 100 }} transition={{ duration: 1, ease: \"easeOut\" }} \/&gt;<\/code> will take one second to complete. It&#8217;s important to understand that the <code>animate<\/code> prop can also be used to chain multiple animations over time by using keyframes. Simply pass an array of values to any animatable property: <code>animate={{ x: [0, 100, 50] }}<\/code> will move the element from its current x (0) to 100, then back to 50, with equal duration segments per keyframe (unless you specify a transition with times). Try creating a simple colored box and watch it slide to the right when the component mounts.<\/p>\n<h3>Step 2: Defining Initial States and Using Variants<\/h3>\n<p>Often you want the element to start off-screen or invisible and then animate into view. The <code>initial<\/code> prop allows you to set the starting state of the animation. Combine it with the <code>animate<\/code> prop to create a mount animation. For example: <code>&lt;motion.div initial={{ opacity: 0, scale: 0.5 }} animate={{ opacity: 1, scale: 1 }} \/&gt;<\/code>. This will cause the element to fade in and grow from half its size. While this approach works for simple cases, Framer Motion introduces a more powerful concept called <strong>variants<\/strong>. Variants allow you to define named animation states and orchestrate them across multiple components or even children. Instead of writing <code>initial<\/code> and <code>animate<\/code> objects inline, you define a <code>variants<\/code> object with keys like &#8220;hidden&#8221;, &#8220;visible&#8221;, &#8220;exit&#8221;, etc. Each variant can contain any animatable properties and a <code>transition<\/code> object. Then you pass the <code>initial<\/code> and <code>whileInView<\/code> (or <code>animate<\/code>) props with the variant name. For example:<\/p>\n<pre style=\"background:#f5f5f5;padding:1em;border-radius:4px;\"><code>\nconst boxVariants = {\n  hidden: { opacity: 0, x: -100 },\n  visible: { opacity: 1, x: 0, transition: { duration: 0.5 } }\n};\n\/\/ Usage:\n&lt;motion.div variants={boxVariants} initial=\"hidden\" animate=\"visible\" \/&gt;\n<\/code><\/pre>\n<p>Variants are especially useful when you want to stagger animations among children. By adding <code>transition={{ staggerChildren: 0.1 }}<\/code> to the parent&#8217;s <code>visible<\/code> variant, each child element will animate one after another with a 100ms delay. This creates a cascading effect that is both elegant and easy to implement. Variants also support <code>when: \"beforeChildren\"<\/code> or <code>afterChildren<\/code>, giving you fine control over the order of animation. Mastering variants is the key to building complex, coordinated animations without messy <code>setTimeout<\/code> calls.<\/p>\n<h3>Step 3: Adding Gesture Animations (Hover, Tap, Drag)<\/h3>\n<p>Interactive animations respond to user input. Framer Motion provides several gesture props that work out of the box: <code>whileHover<\/code>, <code>whileTap<\/code>, <code>whileFocus<\/code>, <code>whileInView<\/code>, and <code>whileDrag<\/code>. Each of these props accepts an object of animatable properties (similar to <code>animate<\/code>) that are activated when the corresponding event occurs. For example, to make a button scale up slightly when hovered and press down when clicked, you can write: <code>&lt;motion.button whileHover={{ scale: 1.1 }} whileTap={{ scale: 0.95 }}&gt;Click Me&lt;\/motion.button&gt;<\/code>. The transitions for these gestures can be customized using the <code>transition<\/code> prop placed directly on the motion component or nested inside each gesture object. For drag, you need to set the <code>drag<\/code> prop to <code>\"x\"<\/code>, <code>\"y\"<\/code>, or <code>true<\/code> for both axes, and then optionally use <code>dragConstraints<\/code> to limit the draggable area. A draggable card that snaps back to its original position after release can be created with <code>&lt;motion.div drag=\"x\" dragConstraints={{ left: -100, right: 100 }} whileDrag={{ scale: 1.2 }} \/&gt;<\/code>. Gesture animations are highly optimized and respect the <code>layout<\/code> prop as well. They are the perfect way to add polish to UI elements like buttons, cards, and modals.<\/p>\n<h3>Step 4: Managing Enter and Exit Animations with <code>AnimatePresence<\/code><\/h3>\n<p>In React, when a component is conditionally rendered using <code>{show && &lt;Component \/&gt;}<\/code>, it appears or disappears instantly. To animate the mounting and unmounting of components, you need to wrap them with <code>AnimatePresence<\/code>. This component detects when children are added or removed and applies the defined exit animations. To use it, import <code>AnimatePresence<\/code> from <code>framer-motion<\/code> and wrap the conditional block. Then, on the motion child, add an <code>exit<\/code> prop that defines its final state before removal. For example:<\/p>\n<pre style=\"background:#f5f5f5;padding:1em;border-radius:4px;\"><code>\nimport { AnimatePresence, motion } from 'framer-motion';\nfunction Modal({ isOpen }) {\n  return (\n    &lt;AnimatePresence&gt;\n      {isOpen && (\n        &lt;motion.div\n          initial={{ opacity: 0, y: -20 }}\n          animate={{ opacity: 1, y: 0 }}\n          exit={{ opacity: 0, y: 20 }}\n          key=\"modal\"\n        &gt;\n          Content here\n        &lt;\/motion.div&gt;\n      )}\n    &lt;\/AnimatePresence&gt;\n  );\n}\n<\/code><\/pre>\n<p>Important: <code>AnimatePresence<\/code> requires each child to have a unique <code>key<\/code> prop to track entering\/exiting elements. Without it, the library cannot distinguish between components and the exit animation may not work. You can also use <code>mode<\/code> prop on <code>AnimatePresence<\/code> to control how enter and exit animations interact. The default mode <code>\"sync\"<\/code> tries to animate both simultaneously. Use <code>mode=\"wait\"<\/code> if you want the exiting element to finish its animation before the entering element starts, which is useful for page transitions. Additionally, <code>AnimatePresence<\/code> supports <code>initial={false}<\/code> to skip the initial mount animation if the component is already present when the app loads. This pattern is essential for creating smooth transitions between different views in a tabbed interface or a modal.<\/p>\n<h3>Step 5: Layout Animations and Shared Layout IDs<\/h3>\n<p>One of the most powerful features of Framer Motion is the ability to animate changes in an element&#8217;s size, position, or layout automatically. When two elements share the same <code>layoutId<\/code>, Framer Motion will smoothly animate the transformation from one to the other as they swap positions or are rearranged. This is commonly used for list reordering, accordion menus, and page transitions where a thumbnail expands into a full-screen image. To enable layout animation on any motion component, simply add the <code>layout<\/code> prop. For instance, if you have a <code>&lt;motion.div layout&gt;<\/code> inside a flex container, and you change its order or visibility, the element will animate to its new position. You can also combine <code>layout<\/code> with <code>initial<\/code> and <code>animate<\/code> for entrance animations. For shared layout animations across different components (like a button that becomes a full card), assign the same <code>layoutId<\/code> string to both elements. When one is removed and the other appears, Framer Motion will interpolate the bounding box, creating a seamless morphing effect. This is perfect for routing transitions in Next.js or React Router. You can even animate layout changes conditionally using <code>layoutDependency<\/code> prop. However, be aware that layout animations require the parent element to have <code>position: relative<\/code> or a stacking context. Also, for performance, you can set <code>layout=\"position\"<\/code> to only animate position changes (ignoring size) or <code>layout=\"size\"<\/code> for only size. Using <code>layout<\/code> animations wisely can drastically improve the perceived performance and polish of your application.<\/p>\n<h3>Step 6: Scroll-Triggered Animations Using <code>useInView<\/code> and <code>whileInView<\/code><\/h3>\n<p>Animating elements as they scroll into the viewport is a staple of modern web design. Framer Motion provides two seamless ways to achieve this: the <code>whileInView<\/code> prop (a variant of gesture props) and the <code>useInView<\/code> hook for more control. The simplest approach is to add <code>whileInView<\/code> to a motion component and optionally define an <code>initial<\/code> state. For example, <code>&lt;motion.div initial={{ opacity: 0, y: 50 }} whileInView={{ opacity: 1, y: 0 }} \/&gt;<\/code> will fade and slide up when the element comes into the viewport. You can also set <code>viewport={{ once: true }}<\/code> to ensure the animation only fires once (otherwise it will re-trigger every time the element enters the viewport). For more complex scenarios, the <code>useInView<\/code> hook returns a ref and a boolean indicating whether the element is visible. You can then use that boolean to drive animations via the <code>animate<\/code> prop or a separate <code>useAnimation<\/code> controller. Example:<\/p>\n<pre style=\"background:#f5f5f5;padding:1em;border-radius:4px;\"><code>\nconst ref = useRef(null);\nconst isInView = useInView(ref, { once: true });\nreturn &lt;motion.div ref={ref} animate={isInView ? { opacity: 1, y: 0 } : { opacity: 0, y: 50 }} \/&gt;;\n<\/code><\/pre>\n<p>The <code>useInView<\/code> hook is especially useful when you want to chain multiple animations or conditionally enable\/disable other interactions. You can also configure the threshold (how much of the element must be visible) and root margin using the options object. Scroll-triggered animations are ideal for revealing content gradually as the user scrolls down a landing page, creating a sense of discovery. Always remember to use <code>willChange<\/code> (or let Framer Motion handle it) to optimize performance for elements that animate heavily. Combine scroll animations with <code>layout<\/code> animations for truly interactive storytelling.<\/p>\n<h2>Tips and Best Practices for Framer Motion<\/h2>\n<h3>Tip 1: Optimize Performance by Limiting Animated Properties and Using <code>willChange<\/code><\/h3>\n<p>While Framer Motion is highly optimized, animating too many properties simultaneously or animating layout-heavy properties like <code>width<\/code> and <code>height<\/code> can cause repaints and jank. A general rule is to prefer CSS transforms (like <code>scale<\/code>, <code>translate<\/code>, <code>rotate<\/code>) over <code>width<\/code>, <code>height<\/code>, or <code>top<\/code>\/<code>left<\/code> because transforms are offloaded to the GPU. Framer Motion automatically promotes elements to a new compositing layer when using transforms, but you can further help by setting <code>style={{ willChange: 'transform' }}<\/code> on motion components that animate frequently. Additionally, avoid animating <code>height: 'auto'<\/code> (use <code>layout<\/code> animations instead with explicit start\/end heights). For massive list animations, consider using <code>AnimatePresence<\/code> with <code>positionTransition<\/code> or <code>layout<\/code> sparingly. The <code>useReducedMotion<\/code> hook is also crucial for accessibility\u2014it respects the user&#8217;s system preference for reduced motion and allows you to disable or simplify animations accordingly. Always wrap your animation logic with this hook to create an inclusive experience.<\/p>\n<h3>Tip 2: Leverage Variants and <code>staggerChildren<\/code> for Coordinated Animations<\/h3>\n<p>Writing inline animation objects for dozens of list items is not only tedious but also difficult to maintain. Variants solve this by decoupling the animation definition from the component tree. Define a parent variant with <code>staggerChildren<\/code> and optionally <code>delayChildren<\/code> to control the sequence. For example, a container for a list might have <code>visible: { transition: { staggerChildren: 0.1 } }<\/code>, and each child defines its own <code>hidden<\/code> and <code>visible<\/code> states. This creates a polished cascade effect with minimal code. Variants are also composable\u2014you can nest variants by simply passing them down via the <code>variants<\/code> prop on each motion element. When combined with <code>AnimatePresence<\/code>, you can even stagger exit animations. Best practice: keep variant definitions in a separate constants file or inside the component to avoid prop drilling. Use descriptive names like <code>cardAnimation<\/code> or <code>fadeSlideLeft<\/code> for readability.<\/p>\n<h3>Tip 3: Use <code>useAnimation<\/code> for Imperative Control and Complex Sequences<\/h3>\n<p>Sometimes you need to start an animation based on a user action that is not a direct gesture (e.g., after a fetch completes, or when a state changes). The <code>useAnimation<\/code> hook returns a control object with <code>start<\/code> and <code>stop<\/code> methods. You attach this control to a motion component via the <code>animate<\/code> prop (yes, the same prop can accept either a target object or a control). Then you can call <code>controls.start({ x: 100 })<\/code> imperatively. For sequences, you can chain multiple <code>start<\/code> calls using <code>async\/await<\/code> or promises. For instance:<\/p>\n<pre style=\"background:#f5f5f5;padding:1em;border-radius:4px;\"><code>\nconst controls = useAnimation();\nconst runSequence = async () => {\n  await controls.start({ scale: 1.5 });\n  await controls.start({ x: 200 });\n  controls.start({ rotate: 360 });\n};\n<\/code><\/pre>\n<p>This gives you fine-grained control over timing and can be combined with <code>useCycle<\/code> to toggle between multiple states. However, avoid overusing imperative animations\u2014prefer declarative props like <code>animate<\/code> and <code>whileInView<\/code> when possible, as they are easier to debug and maintain.<\/p>\n<h2>Frequently Asked Questions (FAQ)<\/h2>\n<h3>Q1: Why is my Framer Motion animation not working at all?<\/h3>\n<p>The most common reasons include: forgetting to import <code>motion<\/code> from <code>framer-motion<\/code> (check your import statement), using a standard HTML element like <code>&lt;div&gt;<\/code> instead of <code>&lt;motion.div&gt;<\/code>, or the element not having an initial state different from its animate state. Also ensure that the component is mounted in the React tree and that you haven&#8217;t accidentally set a CSS <code>transform<\/code> property that conflicts with Framer Motion&#8217;s transforms (they will override each other). Check your browser console for errors; sometimes a missing closing tag or a typo in a property name (e.g., <code>opacity<\/code> spelled as <code>opacity<\/code> is fine, but <code>opacitiy<\/code> is not) can break the animation. Another frequent issue is using <code>transition<\/code> inside the <code>animate<\/code> object incorrectly\u2014it should be a separate prop or inside the variant object, not nested inside the target values. Finally, if you&#8217;re using <code>AnimatePresence<\/code>, ensure each child has a unique <code>key<\/code> prop.<\/p>\n<h3>Q2: How do I animate on scroll using Framer Motion?<\/h3>\n<p>You have two main options: use the <code>whileInView<\/code> prop (the easiest) or the <code>useInView<\/code> hook (more control). For <code>whileInView<\/code>, simply add it to a motion component along with an <code>initial<\/code> state and optionally set <code>viewport={{ once: true }}<\/code> to prevent re-triggering. For custom scroll-based animations that depend on the scroll position (e.g., parallax), you can use the <code>useScroll<\/code> hook along with <code>useTransform<\/code> to create values that map scroll offset to animation values. For example:<\/p>\n<pre style=\"background:#f5f5f5;padding:1em;border-radius:4px;\"><code>\nconst { scrollYProgress } = useScroll();\nconst scale = useTransform(scrollYProgress, [0, 1], [0.5, 1]);\nreturn &lt;motion.div style={{ scale }} \/&gt;;\n<\/code><\/pre>\n<p>This allows you to tie animations directly to the scroll progress, enabling advanced effects like fading a header as you scroll down. Always use <code>useTransform<\/code> instead of manually updating styles in a scroll event listener for performance reasons.<\/p>\n<h3>Q3: Can I animate SVG elements with Framer Motion?<\/h3>\n<p>Absolutely. Framer Motion supports all standard SVG elements via the <code>motion<\/code> factory, e.g., <code>motion.circle<\/code>, <code>motion.path<\/code>, <code>motion.rect<\/code>, etc. You can animate SVG-specific properties like <code>pathLength<\/code>, <code>strokeDashoffset<\/code>, <code>fill<\/code>, and <code>stroke<\/code>. The <code>pathLength<\/code> animation is especially popular for drawing strokes. For example, to animate a line drawing effect, set <code>pathLength: 0<\/code> in <code>initial<\/code> and <code>pathLength: 1<\/code> in <code>animate<\/code>. You can also animate <code>cx<\/code>, <code>cy<\/code>, <code>r<\/code>, <code>width<\/code>, <code>height<\/code>, etc. Note that SVG coordinates are not transformed by CSS transforms the same way as HTML elements, but Framer Motion handles the translation correctly. For complex SVG animations, using variants and <code>staggerChildren<\/code> works just as well.<\/p>\n<h3>Q4: How do I chain multiple animations in sequence?<\/h3>\n<p>There are several approaches. The simplest is to use the <code>transition<\/code> prop&#8217;s <code>delay<\/code> property to offset each animation. Alternatively, you can use keyframes in the <code>animate<\/code> prop: <code>animate={{ x: [0, 100, 200], opacity: [1, 0.5, 1] }}<\/code> will run a sequence through the arrays. For more complex chaining, use the <code>useAnimation<\/code> hook with <code>async\/await<\/code> as shown in Tip 3 above. If you&#8217;re using variants, you can set <code>transition={{ delay: 0.5 }}<\/code> on a child variant to start after the parent. The <code>AnimatePresence<\/code> with <code>mode=\"wait\"<\/code> also naturally chains the exit of one component before the enter of another. For chaining multiple unrelated elements, consider using the <code>animationSequence<\/code> API from <code>framer-motion<\/code>&#8216;s older version (v6) or use custom logic with state changes. The key is to avoid nesting <code>setTimeout<\/code> calls; rely on Framer Motion&#8217;s built-in sequencing mechanisms.<\/p>\n<h3>Q5: How do I animate an element&#8217;s height from 0 to auto?<\/h3>\n<p>Animating to <code>auto<\/code> height is tricky because the browser cannot interpolate between a fixed value and <code>auto<\/code>. The recommended approach is to use the <code>layout<\/code> prop. Wrap the content inside a <code>&lt;motion.div layout&gt;<\/code>. When you toggle visibility or change the content&#8217;s size, the parent will animate its height smoothly. However, if you need a true collapse\/expand animation (like an accordion), you can use the <code>AnimatePresence<\/code> with a child that has a fixed height in <code>animate<\/code> (by measuring the clientHeight) or use the <code>height: \"auto\"<\/code> trick by setting the initial value to 0, then in <code>animate<\/code> set a known height (e.g., <code>height: 200<\/code>). But that requires knowing the exact height. A better solution is to measure the child&#8217;s height with a ref and use <code>useState<\/code> to store it, then animate to that value. Framer Motion also provides the <code>overflow: \"hidden\"<\/code> style automatically when animating height with <code>layout<\/code>. For a pure CSS-free approach, set <code>height: 0<\/code> initially, then inside <code>animate<\/code> use <code>height: \"auto\"<\/code>? That still won&#8217;t interpolate. So stick with <code>layout<\/code> animations\u2014they are the most reliable and performant.<\/p>\n<h3>Q6: Can I use Framer Motion with CSS frameworks like Tailwind or Styled Components?<\/h3>\n<p>Yes, absolutely. Framer Motion works with any styling solution. You can combine <code>motion<\/code> components with Tailwind classes by passing tailwind class names to the <code>className<\/code> prop. For example: <code>&lt;motion.div className=\"flex items-center\" animate={{ x: 100 }} \/&gt;<\/code>. With Styled Components, you can create a styled motion component like <code>const StyledBox = styled(motion.div)`` <\/code> and use it normally. However, be cautious: some CSS properties may conflict with Framer Motion&#8217;s animated values (e.g., setting <code>transform<\/code> in a class will be overridden by the animation). The library inherits existing styles and animates from them, but if a CSS rule has higher specificity, it might overwrite the animation&#8217;s final state. The solution is to use the <code>style<\/code> prop for values that you intend to animate dynamic. Also, when using Tailwind&#8217;s <code>hover:<\/code> utilities, they may conflict with <code>whileHover<\/code>. In that case, rely on Framer Motion&#8217;s gesture props instead of Tailwind hover classes.<\/p>\n<h2>Conclusion<\/h2>\n<p>Framer Motion is an extraordinarily powerful library that democratizes animation in React. From simple fades and slides to complex coordinate-based, gesture-driven, and layout-shifting animations, it provides a clean declarative API that integrates with the component lifecycle. In this guide, we&#8217;ve covered the essentials: setting up motion components, using the <code>animate<\/code> prop, leveraging variants for complex sequencing, adding gesture interactivity, managing mount\/unmount animations with <code>AnimatePresence<\/code>, and creating scroll-triggered effects. We also discussed performance best practices, the importance of accessibility with <code>useReducedMotion<\/code>, and answered common questions about SVG animations, chaining, and auto height. Remember that the key to mastering Framer Motion is to think declaratively: define states (initial, animate, exit, hover, etc.) and let the library handle the interpolation. Experiment with the different props, use the official documentation extensively, and don&#8217;t be afraid to combine multiple features like layout + variants + scroll animations. As you build more complex UIs, you&#8217;ll discover that Framer Motion not only saves time but also encourages a mindset of fluid, interactive design. Start small, perhaps by animating a button or a modal, then gradually adopt layout animations for page transitions. With practice, you&#8217;ll be able to create animations that feel natural and elevate the user experience of any React application.<\/p>\n<h3>Reference Tables<\/h3>\n<table style=\"width:100%; border-collapse:collapse; margin:2em 0;\">\n<caption style=\"font-weight:bold; margin-bottom:0.5em;\">Table 1: Common Motion Component Props<\/caption>\n<thead>\n<tr style=\"background:#eee;\">\n<th style=\"padding:8px; border:1px solid #ccc;\">Prop<\/th>\n<th style=\"padding:8px; border:1px solid #ccc;\">Description<\/th>\n<th style=\"padding:8px; border:1px solid #ccc;\">Example Values<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"padding:8px; border:1px solid #ccc;\"><code>initial<\/code><\/td>\n<td style=\"padding:8px; border:1px solid #ccc;\">The starting state of the component before the animation.<br \/>Can be an object or a variant name.<\/td>\n<td style=\"padding:8px; border:1px solid #ccc;\"><code>{{ opacity: 0 }}<\/code> or <code>\"hidden\"<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"padding:8px; border:1px solid #ccc;\"><code>animate<\/code><\/td>\n<td style=\"padding:8px; border:1px solid #ccc;\">The target state to animate to.<br \/>Can be an object, variant name, or animation controls.<\/td>\n<td style=\"padding:8px; border:1px solid #ccc;\"><code>{{ x: 100 }}<\/code> or <code>\"visible\"<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"padding:8px; border:1px solid #ccc;\"><code>exit<\/code><\/td>\n<td style=\"padding:8px; border:1px solid #ccc;\">The state to animate to when the component is removed from the tree (used with <code>AnimatePresence<\/code>).<\/td>\n<td style=\"padding:8px; border:1px solid #ccc;\"><code>{{ opacity: 0 }}<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"padding:8px; border:1px solid #ccc;\"><code>transition<\/code><\/td>\n<td style=\"padding:8px; border:1px solid #ccc;\">Configures duration, easing, delay, and orchestration for the animation.<\/td>\n<td style=\"padding:8px; border:1px solid #ccc;\"><code>{{ duration: 0.5, ease: \"easeOut\" }}<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"padding:8px; border:1px solid #ccc;\"><code>variants<\/code><\/td>\n<td style=\"padding:8px; border:1px solid #ccc;\">An object containing named animation states. Allows orchestration across children.<\/td>\n<td style=\"padding:8px; border:1px solid #ccc;\"><code>{ hidden: {...}, visible: {...} }<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"padding:8px; border:1px solid #ccc;\"><code>layout<\/code><\/td>\n<td style=\"padding:8px; border:1px solid #ccc;\">Enables automatic animation of layout changes (position, size).<\/td>\n<td style=\"padding:8px; border:1px solid #ccc;\"><code>true<\/code> or <code>\"position\"<\/code> or <code>\"size\"<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"padding:8px; border:1px solid #ccc;\"><code>layoutId<\/code><\/td>\n<td style=\"padding:8px; border:1px solid #ccc;\">Shared identifier between different components for cross-component layout animation.<\/td>\n<td style=\"padding:8px; border:1px solid #ccc;\">A unique string like <code>\"card-1\"<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<table style=\"width:100%; border-collapse:collapse; margin:2em 0;\">\n<caption style=\"font-weight:bold; margin-bottom:0.5em;\">Table 2: Gesture and Interaction Props<\/caption>\n<thead>\n<tr style=\"background:#eee;\">\n<th style=\"padding:8px; border:1px solid #ccc;\">Prop<\/th>\n<th style=\"padding:8px; border:1px solid #ccc;\">When It Triggers<\/th>\n<th style=\"padding:8px; border:1px solid #ccc;\">Common Use Case<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"padding:8px; border:1px solid #ccc;\"><code>whileHover<\/code><\/td>\n<td style=\"padding:8px; border:1px solid #ccc;\">User hovers over the element (mouse pointer enters).<\/td>\n<td style=\"padding:8px; border:1px solid #ccc;\">Scale up a button on hover.<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:8px; border:1px solid #ccc;\"><code>whileTap<\/code><\/td>\n<td style=\"padding:8px; border:1px solid #ccc;\">User presses (mousedown \/ touchstart) on the element.<\/td>\n<td style=\"padding:8px; border:1px solid #ccc;\">Create a press-down effect.<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:8px; border:1px solid #ccc;\"><code>whileFocus<\/code><\/td \n\n","protected":false},"excerpt":{"rendered":"<p>Mastering Framer Motion: The Ultimate Guide to Animating React Apps Framer Motion is a production-ready motion library for React that makes creating fluid, declarative animations remarkably simple. Whether you&#8217;re building a landing page with subtle micro-interactions or a complex UI with shared layout animations and gesture-driven transitions, Framer Motion provides a powerful yet intuitive API. &hellip; <\/p>\n","protected":false},"author":2716,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"footnotes":""},"categories":[],"tags":[],"class_list":["post-1086","post","type-post","status-publish","format-standard","hentry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/posts\/1086","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/users\/2716"}],"replies":[{"embeddable":true,"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/comments?post=1086"}],"version-history":[{"count":0,"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/posts\/1086\/revisions"}],"wp:attachment":[{"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/media?parent=1086"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/categories?post=1086"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/tags?post=1086"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}