A simple and powerful JavaScript animation library
Framer Motion is a production-grade animation library for React that treats animations as first-class components rather than imperative side effects. With over 22 million weekly downloads, it has become the de facto standard for declarative animations in the React ecosystem. The library wraps standard HTML and SVG elements with motion components that accept animation props directly in JSX, eliminating the need for separate animation logic or lifecycle management.
The library solves a fundamental problem in React development: coordinating animations with component state and the virtual DOM. Traditional animation libraries often conflict with React's rendering model, requiring manual DOM manipulation or complex useEffect hooks. Framer Motion integrates seamlessly with React's component lifecycle, automatically handling mounting, unmounting, and re-render scenarios. Its gesture system provides built-in hover, tap, drag, and focus interactions without additional event handlers.
Originally built by the Framer design tool team, the library combines a high-level declarative API with performance optimizations like GPU-accelerated transforms and tree-shakable features. Recent rebranding to "Motion" expanded its scope beyond React to include vanilla JavaScript and Vue support, though React remains its primary use case. The library includes TypeScript definitions, comprehensive test coverage, and supports both spring-based physics animations and traditional keyframe timing.
Developers building interactive UIs, micro-interactions, page transitions, or scroll-driven experiences choose Framer Motion for its balance of simplicity and power. Companies using React at scale rely on it for consistent motion design across component libraries. While it adds approximately 25kb to bundle size (reducible to under 5kb with lazy loading), its integration quality and feature completeness justify the footprint for most animation-heavy applications.
import { motion, AnimatePresence } from 'framer-motion';
import { useState } from 'react';
function NotificationList() {
const [notifications, setNotifications] = useState([
{ id: 1, text: 'Build completed' },
{ id: 2, text: 'Tests passed' }
]);
const removeNotification = (id) => {
setNotifications(prev => prev.filter(n => n.id !== id));
};
return (
<div style={{ padding: 20 }}>
<AnimatePresence mode="popLayout">
{notifications.map(notification => (
<motion.div
key={notification.id}
layout
initial={{ opacity: 0, x: -100 }}
animate={{ opacity: 1, x: 0 }}
exit={{ opacity: 0, x: 100, transition: { duration: 0.2 } }}
whileHover={{ scale: 1.02 }}
whileTap={{ scale: 0.98 }}
style={{
padding: '16px',
marginBottom: '8px',
background: '#f0f0f0',
borderRadius: '8px',
cursor: 'pointer'
}}
onClick={() => removeNotification(notification.id)}
>
{notification.text}
</motion.div>
))}
</AnimatePresence>
</div>
);
}Interactive UI Components: Button press states, dropdown menus, tooltips, and modal dialogs benefit from whileHover, whileTap, and AnimatePresence for smooth enter/exit transitions without manually managing mounting states.
Page Transitions: Single-page applications use AnimatePresence with route changes to animate entire page layouts in and out, creating app-like navigation experiences with stagger effects and coordinated element animations.
Drag-and-Drop Interfaces: The drag gesture system with constraints and momentum physics enables kanban boards, sortable lists, and draggable cards with spring-based snapping and collision detection built in.
Scroll-Driven Animations: Parallax effects, progress indicators, and reveal animations trigger based on scroll position using useScroll and useTransform hooks, mapping viewport progress to opacity, scale, or position values.
Layout Animations: Responsive components that expand/collapse, reorder, or change grid layouts animate automatically with the layout prop, which morphs between states using FLIP technique for 60fps performance even on complex DOM changes.
GSAP is a framework-agnostic JavaScript animation library that turns developers into animation superheroes. Build high-performance animations that work in **every** major browser. Animate CSS, SVG, canvas, React, Vue, WebGL, colors, strings, motion paths,
<p align="center"> <img src="https://i.imgur.com/QZownhg.png" width="240" /> </p>
npm install framer-motionpnpm add framer-motionbun add framer-motion