Transition & Animation
# Transition & Animation
# Usage
Wrap the element or component that needs animation in a <transition> tag with a custom name. Vue will add corresponding CSS class names based on the element's toggle (enter/leave) process, allowing you to freely use CSS class names to set CSS transitions & animations.
# Transition Class Names
There are 6 class switches during the enter/leave transition.
Class name lifecycle
Enter
v-enteronly exists on the first framev-enter-activefrom first frame to last frame, removed when finishedv-enter-tofrom second frame to last frame, removed when finished
Leave
v-leaveonly exists on the first framev-leave-activefrom first frame to last frame, removed when finishedv-leave-tofrom second frame to last frame, removed when finished
If you use a <transition> without a name, then v- is the default prefix for these class names. If you use name="fade", then the v- prefix will be replaced with fade-.
# CSS Transition Demo
See the Pen vue的过渡动画 by xugaoyi (@xugaoyi) on CodePen.
# CSS Animation Demo
See the Pen vue的动画 by xugaoyi (@xugaoyi) on CodePen.
# Example Usage in a Component
<template>
<transition name="slide">
<div class="add-song">
...
</div>
</transition>
<template>
1
2
3
4
5
6
7
2
3
4
5
6
7
.add-song
&.slide-enter-active, &.slide-leave-active
transition: all 0.3s
&.slide-enter, &.slide-leave-to
transform: translate3d(100%, 0, 0)
1
2
3
4
5
2
3
4
5
Edit (opens new window)
Last Updated: 2026/03/21, 12:14:36