
Framer Motion Has a Free API That Makes React Animations Effortless
Framer Motion (now Motion) is React's most powerful animation library. Its API surface goes far beyond simple animate props. Layout Animations: Zero-Config Magic import { motion } from " framer-motion " ; function ExpandableCard ({ isOpen }) { return ( < motion . div layout > < motion . h2 layout = "position" > Card Title </ motion . h2 > { isOpen && ( < motion . p initial = { { opacity : 0 } } animate = { { opacity : 1 } } exit = { { opacity : 0 } } > Expanded content here </ motion . p > ) } </ motion . div > ); } Just add layout — Motion automatically animates between any layout change. Size, position, flexbox reflows — all smooth. Gesture API: Drag, Hover, Tap < motion . div drag dragConstraints = { { left : - 100 , right : 100 , top : - 50 , bottom : 50 } } dragElastic = { 0.2 } whileHover = { { scale : 1.05 } } whileTap = { { scale : 0.95 } } whileDrag = { { cursor : " grabbing " } } onDragEnd = { ( event , info ) => { if ( info . offset . x > 100 ) dismissCard (); } } /> Scroll-
Continue reading on Dev.to React
Opens in a new tab



