All components

MotionPresence

Keeps content mounted while it animates in and out.

WebReact NativeContent and size

Try it

Preparing the example…

Shortest usage

Notice.jsx
<MotionPresence present={visible} exit={{ opacity: 0, translateY: -12 }}>
  Draft saved
</MotionPresence>;

What it handles for you

  • Change present instead of unmounting; the content leaves before it is removed.
  • Restoring during an exit continues from the current values.
  • Content that appears again enters from the exit pose.
  • The first render shows it at rest, so content that is already there does not flash.

Use it for

  • A saved-draft notice.
  • A coupon message in a checkout.
  • An error message under a field.

Props

PropTypeDefaultDescription
presentboolean—requiredShow or hide the content. Change this instead of unmounting.
enterPose{ opacity: 1, translateY: 0 }The pose at rest.
exitPose{ opacity: 0, translateY: -12 }The pose the content leaves with and enters from.
aselement'div'The element to render.
transitionTransitionspringA timing curve { duration, easing } or a spring { tempo: 'spring', spring }. Springs keep their momentum when interrupted.
onExitComplete() => voidRuns after the content has left and been removed.

Other props go to the rendered element, so className, style and event handlers work as usual.

Web and React Native

Poses use opacity, translateX, translateY, scale, scaleX, scaleY, rotate, width and height. onExitComplete runs after the content has left.

The same poses and props work on React Native.

Used in these examples

Search

Type to search the documentation.