Dec 19, 2024
motion
components provide various gesture animation props:
whileHover
whileTap
whileFocus
whileDrag
whileInView
<motion.button
whileHover={{ scale: 1.2, transition: { duration: 1 } }}
whileTap={{ scale: 0.9 }}
/>
variants
prop.<motion.button
whileTap="tap"
whileHover="hover"
variants={buttonVariants}
>
<svg>
<motion.path variants={iconVariants} />
</svg>
</motion.button>
<motion.a
whileHover={{ scale: 1.2 }}
onHoverStart={event => {}}
onHoverEnd={event => {}}
/>
tap
: Fires when the tap ends on the same component.tapCancel
: Fires if the tap ends outside the component.<motion.button whileTap={{ scale: 0.9, rotate: 3 }} />
Enter
triggers tap events on focused elements.<motion.div onPan={(e, pointInfo) => {}} />
<motion.div drag whileDrag={{ scale: 1.2, backgroundColor: "#f00" }} />
<motion.a whileFocus={{ scale: 1.2 }} href="#" />
Capture
React props.<motion.div whileTap={{ scale: 2 }}>
<button onPointerDownCapture={e => e.stopPropagation()} />
</motion.div>
filter
components.while-
props and event handlers on parent elements with variants.