Component Props
All moti components have a few useful props:
animateMagically animate any value passed herefromThe initial animation styles when the component mountsexitUnmount animation styles. This works the exact same asframer-motion's exit prop, and requires wrapping your component withAnimatePresence. The only difference is you importAnimatePresencefrommoti.transitionTake full control over your animation configuration. You can set options for your entire animtation (such astype: 'timing'), or set transition options per-style (translateY: { type: 'timing' }).exitTransitionThe exact same astransition, except that it only applies toexitanimations.stateIf you're using theuseAnimationStatehook, you should pass the state it returns to this prop.onDidAnimateCallback function called after finishing a given animation.- First argument is the style prop string (
opacity,scale, etc.) - The second argument is whether the animation
finishedor not (boolean) - The third argument is
value, which only exists in a sequence. - The fourth argument is an event dictionary.
- It has an
attemptedValuefield, which indicates the value that the animation tried to get to. - This is probably a better field to check for than the third argument.
- As long as the second argument,
finished, istrue, then theattemptedValuerepresents that the value that was animated to.
- It has an
- First argument is the style prop string (
exitTransition#
Define animation configurations for exiting components.
Options passed to exitTransition will only apply to the exit prop, when a component is exiting.
By default, exit uses transition to configure its animations, so this prop is not required.
However, if you pass exitTransition, it will override transition for exit animations.
To see how to use this prop, see the transition docs.