# 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.

- Category: [Window & layout](https://tarve.dev/docs.md#layout)
- Import: `import { AnimatePresence } from "@tarve/core";`
- Props type: `AnimatePresenceProps`
- Source: [packages/core/src/motion.ts:128](https://github.com/omarcosr/tarve/blob/main/packages/core/src/motion.ts#L128)

## Usage

```tsx title="AnimatePresence.tsx"
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 | Description |
| --- | --- | --- | --- |
| `children` (required) | `VNode` | — |  |
| `exit` (required) | `MotionValues` | — | Numeric targets held until their native transitions finish. |
| `id` (required) | `string` | — | Stable identity for this presence boundary. |
| `present` (required) | `boolean` | — |  |
| `enter` | `MotionValues` | — | Initial numeric values applied when the native node is first mounted. |
| `transition` | `MotionTransitions` | — | Overrides the child's style.transition for enter/exit motion. |

## Types

```ts title="MotionTransitions"
type MotionTransitions = Partial<Record<MotionProperty | "all", MotionTransition>>;
```

```ts title="MotionValues"
type MotionValues = Partial<Record<NumericMotionProperty, number>> & { transform?: Transform | string };
```

Previous: [Separator](https://tarve.dev/docs/components/Separator.md) · Next: [Glass](https://tarve.dev/docs/components/Glass.md)

---

Tarve v0.13.8 · HTML version: https://tarve.dev/docs/components/AnimatePresence · Index for agents: https://tarve.dev/llms.txt
