Optional animateOptional exitA target to animate to when this component is removed from the tree.
This component must be the first animatable child of an AnimatePresence to enable this exit animation.
This limitation exists because React doesn't allow components to defer unmounting until after
an animation is complete. Once this limitation is fixed, the AnimatePresence component will be unnecessary.
import { AnimatePresence, motion } from 'framer-motion'
export const MyComponent = ({ isVisible }) => {
return (
<AnimatePresence>
{isVisible && (
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
/>
)}
</AnimatePresence>
)
}
Optional initialProperties, variant label or array of variant labels to start in.
Set to false to initialise with the values in animate (disabling the mount animation)
// As values
<motion.div initial={{ opacity: 1 }} />
// As variant
<motion.div initial="visible" variants={variants} />
// Multiple variants
<motion.div initial={["visible", "active"]} variants={variants} />
// As false (disable mount animation)
<motion.div initial={false} animate={{ opacity: 0 }} />
Optional transitionDefault transition. If no transition is defined in animate, it will use the transition defined here.
const spring = {
type: "spring",
damping: 10,
stiffness: 100
}
<motion.div transition={spring} animate={{ scale: 1.2 }} />
Optional variantsVariants allow you to define animation states and organise them by name. They allow
you to control animations throughout a component tree by switching a single animate prop.
Using transition options like delayChildren and staggerChildren, you can orchestrate
when children animations play relative to their parent.
After passing variants to one or more motion component's variants prop, these variants
can be used in place of values on the animate, initial, whileFocus, whileTap and whileHover props.
const variants = {
active: {
backgroundColor: "#f00"
},
inactive: {
backgroundColor: "#fff",
transition: { duration: 2 }
}
}
<motion.div variants={variants} animate="active" />
Generated using TypeDoc
Values to animate to, variant label(s), or
AnimationControls.