When using repeat
, you can add a repeatType
of "reverse"
to make the animation go back and forth.
export function Example() {
return (
<motion.div
style={{
width: 150,
height: 150,
borderRadius: 30,
backgroundColor: "#fff"
}}
animate={{ rotate: 360 }}
transition={{
duration: 2,
repeat: Infinity,
repeatType: "reverse"
}}
/>
);
}