All components
MotionPresence
Keeps content mounted while it animates in and out.
WebReact NativeContent and size
Try it
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
| Prop | Type | Default | Description |
|---|
present | boolean | —required | Show or hide the content. Change this instead of unmounting. |
|---|
enter | Pose | { opacity: 1, translateY: 0 } | The pose at rest. |
|---|
exit | Pose | { opacity: 0, translateY: -12 } | The pose the content leaves with and enters from. |
|---|
as | element | 'div' | The element to render. |
|---|
transition | Transition | spring | A timing curve { duration, easing } or a spring { tempo: 'spring', spring }. Springs keep their momentum when interrupted. |
|---|
onExitComplete | () => void | | Runs after the content has left and been removed. |
|---|
Other props go to the rendered element, so className, style and event handlers work as usual.