Search⌘ K
AI Features

Transitions

Discover how to apply Vue's built-in transition components to enhance your application's UI with smooth animations. Explore customizing CSS classes, event hooks, and using transition groups for list animations. Gain hands-on practice with both the transition and transition-group components, and learn to integrate popular animation libraries like Animate.css and Tailwind for versatile effects.

Transitions make every app more attractive to the users. They add exciting details, make rendering smoother, and make changes to the UI more comprehensible. With modern CSS, we can add transitions to any element we like. Vue dedicates an entire component to transitions.

The <transition> component

The <transition> component is built-in and allows us to add transitions to every component. It adds CSS classes to the content defined in the default slot by default. Let’s look at a simple example of using the <transition> component that has all default values.

HTML
<template>
<div>
<transition>
<div> <!-- This element will be animated -->
</div>
</transition>
</div>
</template>

The <transition> component offers several props with which we can steer its behavior:

  • name: This is the name of the transition. It customizes the used CSS classes.
  • type: This can be either animation or transition. It determines how Vue attaches event listeners and selects when to attach and detach CSS classes.
...