Skip to main content
InterviewHubPRO
Section Overview
Q46

Question 46 of 50

Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

92%
Vue.js & Composition API (50 Qs)•Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

Vue 3 `<Transition>` and `<TransitionGroup>`: Classes, Hooks, and FLIP Animations.

senior LevelCode ExampleHooksSystem DesignVue & Nuxt

In Simple Words:

  • <Transition>: Applies CSS enter/leave transition classes (v-enter-from, v-enter-active, v-enter-to, v-leave-from, v-leave-active, v-leave-to) to single elements or dynamic components.
  • <TransitionGroup>: Animates lists of items when elements are inserted, removed, or reordered using FLIP (First, Last, Invert, Play) algorithms with the .v-move class.
vue
<template>
  <!-- List animation using TransitionGroup -->
  <TransitionGroup name="list" tag="ul">
    <li v-for="item in items" :key="item.id">
      {{ item.text }}
    </li>
  </TransitionGroup>
</template>

<style scoped>
.list-move, /* Applied to moving elements during reorder */
.list-enter-active,
.list-leave-active {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.list-enter-from,
.list-leave-to {
  opacity: 0;
  transform: translateY(20px);
}
.list-leave-active {
  position: absolute; /* Ensures smooth reordering of remaining elements */
}
</style>