AnimatePresence
Keeps a child mounted while its native exit animation runs.
Keeps one native child alive while its exit targets are animated by the Rust renderer. Keep the boundary itself mounted and toggle `present` so Tarve can retain native identity.
Import
import { AnimatePresence } from "@tarve/core";Usage
import { Alert, AnimatePresence, Button, Column } from "@tarve/core";
let visible = true;
<Column gap={16} align="center" style={{ width: 380 }}>
<Button
variant="outline"
onClick={() => {
visible = !visible;
}}
>
{visible ? "Dismiss banner" : "Show banner"}
</Button>
<Column style={{ width: 380, height: 84 }}>
<AnimatePresence
id="saved-banner"
present={visible}
enter={{ opacity: 0, top: 16 }}
exit={{ opacity: 0, top: -16 }}
transition={{ all: { duration: 320, easing: "easeOut" } }}
>
<Column style={{ position: "relative", top: 0, opacity: 1 }}>
<Alert variant="success" title="Saved" description="Your changes are live." />
</Column>
</AnimatePresence>
</Column>
</Column>Props
| Prop | Type | Default |
|---|---|---|
children required | VNode | — |
exit required Numeric targets held until their native transitions finish. | MotionValues | — |
id required Stable identity for this presence boundary. | string | — |
present required | boolean | — |
enter Initial numeric values applied when the native node is first mounted. | MotionValues | — |
transition Overrides the child's style.transition for enter/exit motion. | MotionTransitions | — |
Types
type MotionTransitions = Partial<Record<MotionProperty | "all", MotionTransition>>;type MotionValues = Partial<Record<NumericMotionProperty, number>> & { transform?: Transform | string };