---
title: "Transition"
description: "Vue's <Transition> with AnimeJS enter and leave animations."
canonical_url: "https://nanimejs.netlify.app/components/transition"
---
# Transition

> Vue's <Transition> with AnimeJS enter and leave animations.

`<AnimeTransition>` works like Vue's
[`<Transition>`](https://vuejs.org/guide/built-ins/transition.html), with
AnimeJS running the enter and leave animations instead of CSS classes. It
takes one child, toggled by `v-if`, `v-show` or a changed `key`.

## Chain steps with keyframes

<render-code-block-preview src="examples/components/TransitionKeyframesDemo.vue">



</render-code-block-preview>

A function value runs each time the element leaves, so each leave goes
somewhere new.

## API

<field-group>
<field name="animation" type="AnimeTransitionStyleName | AnimeTransitionAnimation">

Enter and leave together. A style name sets both, or pass
`{ enter, leave }`. Defaults to `'fade'`: 300ms in and 200ms out.
[Defaults](https://nanimejs.netlify.app/guides/defaults) sets another for the app.

</field>

<field name="enterAnimation" type="AnimeTransitionStyleName | AnimationParams">

Overrides the enter in `animation`.

</field>

<field name="leaveAnimation" type="AnimeTransitionStyleName | AnimationParams">

Overrides the leave in `animation`.

</field>

<field name="mode" type="'default' | 'in-out' | 'out-in'">

Order when one element replaces another. Defaults to `'default'`.

</field>

<field name="appear" type="boolean">

Run the enter animation on the first render too. Defaults to `false`.

</field>

<field name="waapi" type="boolean">

Run the enter and leave with `waapi.animate()` instead of `animate()`.
The animation props then take `waapi.animate()` params. Defaults to
`false`.

</field>

<field name="completeOnTabHidden" type="boolean">

Jump running animations to their end when the browser tab is hidden.
Defaults to `false`.

</field>
</field-group>

With reduced motion on, the element jumps to its end state. See
[Accessibility](https://nanimejs.netlify.app/guides/accessibility).

Vue's transition events pass through, and `nanime` calls the `done`
callback of `@enter` and `@leave` when the animation finishes.

### Set enter and leave with `animation`

```vue [App.vue]
<AnimeTransition animation="slide-up" />

<AnimeTransition :animation="{ enter: 'slide-up', leave: 'fade' }" />
```

With `animation="fade"` and `enter-animation="scale"`, the element enters
with `scale` and leaves with `fade`.

## Swap keyed elements with `mode`

<render-code-block-preview src="examples/components/TransitionModeDemo.vue">



</render-code-block-preview>

`out-in` waits for the old element to finish leaving, `in-out` enters the
new one first, and `default` runs both at once.

## Keep transitions smooth during hydration with `waapi`

```vue [App.vue]
<AnimeTransition waapi :enter-animation="{ opacity: [0, 1], y: [8, 0], duration: 300 }">
  <div v-if="open" class="panel" />
</AnimeTransition>
```

Hydration keeps the main thread busy, which stalls `animate()`. The browser
runs [`waapi.animate()`](https://nanimejs.netlify.app/composables/use-waapi-animate) animations off the
main thread, so they keep playing.

<note>

A style that `waapi.animate()` cannot run, such as one with keyframe objects
or a function value, runs on `animate()` and logs a warning in development.

</note>

## Finish animations when the tab is hidden

AnimeJS pauses its animations while the browser tab is hidden, so a
leaving element stays half faded. Set `completeOnTabHidden` to jump the
component's running animations to their end instead.

To turn it on for every instance, set it in `nanime.components` in
`app.config.ts`:

```ts [app/app.config.ts]
export default defineAppConfig({
  nanime: {
    components: { transition: { completeOnTabHidden: true } },
  },
})
```

`transitionGroup` and `layoutGroup` take the same key.

## See also

- [`<AnimeTransitionGroup>`](https://nanimejs.netlify.app/components/transition-group): animate `v-for` lists
- [Transition styles](https://nanimejs.netlify.app/components/transition-styles): the built-in style names
- [Defaults](https://nanimejs.netlify.app/guides/defaults): set the props for the whole app


## Sitemap

See the full [sitemap](https://nanimejs.netlify.app/sitemap.md) for all pages.
