--- title: TransitionGroup Component Best Practices impact: MEDIUM impactDescription: TransitionGroup animates list items; missing keys or misuse leads to broken list transitions type: best-practice tags: [vue3, transition-group, animation, lists, keys] --- # TransitionGroup Component Best Practices **Impact: MEDIUM** - `` animates lists of items entering, leaving, and moving. Use it for `v-for` lists or dynamic collections where individual items change over time. ## Task List - Use `` only for lists and repeated items - Provide unique, stable keys for every direct child - Use `tag` when you need semantic or layout wrappers - Avoid the `mode` prop (not supported) - Use JavaScript hooks for staggered effects ## Use TransitionGroup for Lists `` is designed for list items. Use `tag` to control the wrapper element when needed. **BAD:** ```vue ``` **GOOD:** ```vue ``` ## Always Provide Stable Keys Keys are required. Without stable keys, Vue cannot track item positions and animations break. **BAD:** ```vue ``` **GOOD:** ```vue ``` ## Do Not Use `mode` on TransitionGroup `mode` is only for `` because it swaps a single element. Use `` if you need in/out sequencing. **BAD:** ```vue ``` **GOOD:** ```vue ``` ## Stagger List Animations with Data Attributes For cascading list animations, pass the index to JavaScript hooks and compute delay per item. ```vue ```