framer-motion

v12.38.0 MIT

A simple and powerful JavaScript animation library

Weekly Downloads
31.4M
Stars
31.4K
Forks
1.1K
Open Issues
174
Gzip Size
65.3 kB
Unpacked Size
4.7 MB
Dependencies
4
Last Updated
1mo ago

framer-motion Download Trends

Download trends for framer-motion043.2M86.4M129.6M172.8MFeb 2025MayAugNovFebApr 2026
framer-motion

About framer-motion

Framer Motion is a declarative animation library built for React, designed to simplify the creation of complex animations within web applications. It addresses the common challenge of integrating fluid and engaging motion into user interfaces, solving the often tedious process of manually managing animation states, CSS transitions, or complex JavaScript timelines.

Its core philosophy centers on creating expressive and accessible animations with minimal code. The library is primarily aimed at React developers who want to add sophisticated visual feedback and micro-interactions without diving deep into animation specifics. It aims to make animation an intuitive part of the component lifecycle.

Key API patterns revolve around the `motion` component and various hooks. Developers can wrap standard HTML elements with `motion.` (e.g., `motion.div`) to enable animation capabilities. Properties like `animate`, `initial`, `exit`, and `transition` are used directly on these components to define animation states and their associated properties, including springs and keyframes, which are central to its expressive power.

Framer Motion integrates seamlessly with React, including support for hooks like `useAnimation` for imperative control and `useMotionValue` for tracking and reacting to animation values. It plays well with build tools commonly used in the React ecosystem and can be straightforwardly incorporated into existing projects. Its focus on React components makes it a natural fit for modern React development workflows.

The package is notably large at 4.7 MB unpacked, contributing to a gzipped bundle size of 58.7 kB. While this is a significant contribution to the bundle, it offers a comprehensive feature set for animation. The library is more mature than many alternatives, boasting 31.2K GitHub stars and significant adoption, as indicated by its 30.5M weekly downloads.

Developers should be aware that its declarative nature, while powerful, can sometimes abstract away granular control that might be present in lower-level animation APIs. For extremely simple, one-off CSS transitions, entirely different approaches might offer a smaller footprint. Additionally, while it supports server-side rendering, careful consideration is needed for animations that rely on client-side JavaScript to initialize correctly.

When to use

  • When creating interactive UI elements that require animating properties like position, scale, opacity, or color using a declarative API.
  • To implement gesture-based animations, such as drag-and-drop interfaces or parallax scrolling effects, powered by the `useDrag` hook.
  • For complex entrance and exit animations of components within React applications, utilizing the `AnimatePresence` component.
  • To define physics-based animations, like springs and tweening, by configuring the `transition` prop with predefined or custom spring settings.
  • When building custom SVG animations by applying the `motion` prefix to SVG elements like `motion.path` or `motion.circle`.
  • To integrate layout animations that smoothly transition elements when their position or size changes on the screen using `AnimatePresence`.
  • For orchestrating sequences of animations or controlling animations imperatively via the `useAnimation` hook.

When NOT to use

  • If your sole requirement is simple CSS transitions triggered by hover or focus states — standard CSS or React's `useState` with class toggling may suffice with less overhead.
  • When building highly performance-critical animations that demand absolute minimal JavaScript execution and rely on hardware-accelerated CSS properties exclusively.
  • If integrating into a framework or environment that fundamentally does not support client-side JavaScript rendering or React component lifecycles.
  • For animations that are purely decorative and do not enhance user experience or provide necessary feedback; consider the performance trade-offs.
  • If you need to animate elements outside the standard DOM tree or employ global animation loops not managed by React's rendering cycle, alternative libraries might offer more control.

framer-motion Alternatives

framer-motion Categories