KoderSolutionKoderSolution LogoKoderSolution Logo
HomeArticlesTutorialsToolsRun CodeForumAI Lab
🖖

Vue

Topic Hub & Articles

Vue Intro

10 min

Recap Quiz

Gated

Milestone Assessment

Vue Get Started

10 min

Vue Directives

10 min

Vue Events

10 min

Recap Quiz

Gated

Milestone Assessment

Vue Forms

10 min

Vue Components

10 min

Vue Props

10 min

Recap Quiz

Gated

Milestone Assessment

Vue Methods

10 min

Vue Computed Properties

10 min

Vue Watchers

10 min

Recap Quiz

Gated

Milestone Assessment

Vue Class and Style Bindings

10 min

Vue Conditional Rendering

10 min

Vue List Rendering

10 min

Recap Quiz

Gated

Milestone Assessment

Vue Template Syntax

10 min

Vue Teleport

10 min

Vue Suspense

10 min

Recap Quiz

Gated

Milestone Assessment

Vue Transitions

10 min

Vue Mixins

10 min

Vue Custom Directives

10 min

Recap Quiz

Gated

Milestone Assessment

Vue Plugins

10 min

Vue Slots

10 min

Vue Provide / Inject

10 min

Recap Quiz

Gated

Milestone Assessment

Vue Dynamic Components

10 min

Vue Async Components

10 min

Composition API Intro

10 min

Recap Quiz

Gated

Milestone Assessment

ref vs reactive

10 min

Lifecycle Hooks

10 min

Dependency Injection

10 min

Recap Quiz

Gated

Milestone Assessment

Computed and Watch

10 min

Template Refs

10 min

Composable Functions

10 min

Script Setup

10 min

Progress
0%

0 / 32 Lessons

KoderSolutionKoderSolution LogoKoderSolution Logo

The world’s most advanced technical ecosystem for modern software engineers. Learn, build, and grow with next-generation developer tools and resources.

Facebook PageX (Twitter) ProfileYouTube ChannelContact Support

Engineering Newsletter

Subscribe for weekly software engineering tutorials, architecture guides, and developer tool updates.

Platforms

  • Technical Articles
  • Interactive Tutorials
  • AI Coding Lab
  • Developer Forum
  • Developer Tools

Pages

  • About Us
  • Contact Us
  • Privacy Policy
  • Terms of Service
  • Refund Policy
  • Disclaimer
  • Advertisement

Popular Topics

  • PHP
  • Laravel
  • Python
  • React.Js
  • MySQL
© 2026 KoderSolutionAll Rights Reserved
Developed Bymaksudur.dev
VueVue Tutorial
Lesson

Vue Transitions

10 min reading
Free Course

Vue Transitions: CSS Animations with Transition and TransitionGroup

Vue <Transition> and <TransitionGroup> are built-in components that animate elements when they enter or leave the DOM. Vue applies CSS classes at each step of the animation automatically when v-if, v-show, or dynamic components toggle.

Instead of manually adding and removing CSS timer classes in JavaScript, you define simple CSS rules for enter and leave states. Vue detects the animation duration from CSS and removes elements only after the exit animation finishes.

flowchart LR
    EnterFrom["fade-enter-from"] --> EnterActive["fade-enter-active"] --> EnterTo["fade-enter-to"]
    LeaveFrom["fade-leave-from"] --> LeaveActive["fade-leave-active"] --> LeaveTo["fade-leave-to"]

Transition Class Lifecycle

When using <Transition name="fade">, Vue toggles six predictable CSS classes:

  • fade-enter-from and fade-enter-to: Starting and ending styles for elements entering the DOM.
  • fade-enter-active: Active class during the entire enter phase, where you set transition properties.
  • fade-leave-from and fade-leave-to: Starting and ending styles for elements leaving the DOM.
  • fade-leave-active: Active class during the exit animation.

Practical SFC Transition Example

Use <Transition> for a single conditional element and <TransitionGroup> when animating items inside a v-for list.

<script setup>
import { ref } from 'vue';

const showBanner = ref(true);
const items = ref(['Alpha', 'Beta', 'Gamma']);

function addItem() {
  items.value.push(`Item ${items.value.length + 1}`);
}

function removeItem(index) {
  items.value.splice(index, 1);
}
</script>

<template>
  <div class="animation-demo">
    <button @click="showBanner = !showBanner">Toggle Banner</button>

    <Transition name="fade" mode="out-in">
      <div v-if="showBanner" key="banner" class="banner">
        Notification Alert Banner
      </div>
    </Transition>

    <button @click="addItem">Add List Item</button>
    <TransitionGroup name="list" tag="ul">
      <li v-for="(item, index) in items" :key="item">
        <span>{{ item }}</span>
        <button @click="removeItem(index)">x</button>
      </li>
    </TransitionGroup>
  </div>
</template>

<style scoped>
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.3s ease;
}
.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}

.list-enter-active,
.list-leave-active {
  transition: all 0.3s ease;
}
.list-enter-from,
.list-leave-to {
  opacity: 0;
  transform: translateX(24px);
}
</style>

Common Mistakes

  • Missing :key Inside <TransitionGroup>: Every direct child inside <TransitionGroup> must have a unique :key. Without keys, Vue cannot track which list items moved or exited.
  • Putting Two Active Elements in <Transition>: <Transition> animates one element or component at a time. When switching between two elements, ensure only one branch renders at a time or use mode="out-in".
  • Forgetting tag on <TransitionGroup>: Unlike <Transition>, <TransitionGroup> can render a wrapper tag such as tag="ul" so your HTML stays semantic.

Frequently Asked Questions

What does mode="out-in" do on <Transition>?

With mode="out-in", Vue waits for the outgoing element to finish its leave animation before starting the incoming element's enter animation. This prevents two elements from jumping past each other.

Can <Transition> animate on initial page render?

Yes. Add the appear attribute (<Transition name="fade" appear>) to run the enter animation when the component first mounts.

How do I trigger JavaScript animations with libraries like GSAP?

<Transition> emits JavaScript hooks such as @enter, @before-enter, and @leave. Pass :css="false" when driving animations purely with JavaScript.

Save Your Progress

Unlock Your
Full Potential.

Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.

Quick Access With

Enterprise-Grade Security Protocol

Related Developer Tools & Topic Hub

Vue Topic Hub
JSON Formatter
Validate and format JSON payloads
HTML Formatter
Format HTML templates
CSS Formatter
Clean and format stylesheets
All Vue Articles
Deep-dive guides, tips & discussions
PreviousVue Suspense
Continue JourneyNext: Vue Mixins

Stuck on this lesson?

Join our community of senior developers.

Ask in Forum