Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Vue 3 debugging reference for reactivity issues, computed errors, watcher bugs, async failures, and SSR hydration problems.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
reference/transition-group-flip-inline-elements.md
1---2title: TransitionGroup FLIP Animations Do Not Work With Inline Elements3impact: MEDIUM4impactDescription: Move animations silently fail on inline elements, causing items to jump5type: gotcha6tags: [vue3, transition-group, animation, flip, css, display, inline-block]7---89# TransitionGroup FLIP Animations Do Not Work With Inline Elements1011**Impact: MEDIUM** - The FLIP (First, Last, Invert, Play) animation technique that Vue uses for `<TransitionGroup>` move transitions does not work with elements that have `display: inline`. The move animation will silently fail, and items will jump to their new positions instead of smoothly transitioning.1213This is a CSS limitation, not a Vue bug. CSS transforms (which FLIP uses internally) do not apply to inline elements per the CSS specification.1415## Task Checklist1617- [ ] Ensure list items are not `display: inline` elements18- [ ] Use `display: inline-block` or `display: block` for list items19- [ ] Use flexbox or grid containers which make children block-level20- [ ] Check if inherited styles are setting `display: inline`2122**Incorrect - Inline elements break move animations:**23```vue24<template>25<!-- BROKEN: span elements are inline by default -->26<TransitionGroup name="tag" tag="div" class="tag-container">27<span v-for="tag in tags" :key="tag.id" class="tag">28{{ tag.name }}29</span>30</TransitionGroup>31</template>3233<style>34.tag-move {35transition: transform 0.3s ease;36/* This won't work because spans are inline! */37}38</style>39```4041**Correct - Use inline-block:**42```vue43<template>44<TransitionGroup name="tag" tag="div" class="tag-container">45<span v-for="tag in tags" :key="tag.id" class="tag">46{{ tag.name }}47</span>48</TransitionGroup>49</template>5051<style>52.tag {53display: inline-block; /* REQUIRED for FLIP animations */54}5556.tag-move {57transition: transform 0.3s ease;58}59</style>60```6162**Correct - Use flexbox container:**63```vue64<template>65<TransitionGroup name="tag" tag="div" class="tag-container">66<span v-for="tag in tags" :key="tag.id" class="tag">67{{ tag.name }}68</span>69</TransitionGroup>70</template>7172<style>73.tag-container {74display: flex;75flex-wrap: wrap;76gap: 8px;77}7879/* Flex children are block-level, FLIP works automatically */80.tag-move {81transition: transform 0.3s ease;82}83</style>84```8586**Correct - Use block elements:**87```vue88<template>89<!-- div elements are block by default -->90<TransitionGroup name="item" tag="div">91<div v-for="item in items" :key="item.id" class="item">92{{ item.name }}93</div>94</TransitionGroup>95</template>9697<style>98.item-move {99transition: transform 0.3s ease;100}101</style>102```103104## Why Inline Elements Don't Work105106Per CSS specifications, the `transform` property does not apply to inline boxes. Since FLIP animations use CSS transforms to animate element positions:107108```css109/* Vue internally applies something like this during move */110.item {111transform: translateX(-50px) translateY(-20px);112/* Then transitions to transform: none */113}114```115116This transform is ignored on inline elements, so no animation occurs.117118## Elements That Are Inline by Default119120Be aware of these common inline elements that need `display: inline-block`:121122- `<span>`123- `<a>`124- `<em>`, `<strong>`, `<i>`, `<b>`125- `<code>`, `<kbd>`126- `<label>`127- `<button>` (inline-block by default, but verify)128129## Move Animations Also Require Transform Transition130131The `.move` class must have `transform` in its `transition` property:132133```css134/* CORRECT */135.list-move {136transition: transform 0.3s ease;137}138139/* ALSO CORRECT */140.list-move {141transition: all 0.3s ease; /* 'all' includes transform */142}143144/* WRONG - transform not included */145.list-move {146transition: opacity 0.3s ease; /* Move won't animate! */147}148```149150## Reference151- [Vue.js TransitionGroup Move Transitions](https://vuejs.org/guide/built-ins/transition-group.html#move-transitions)152- [MDN CSS Transform - Formal Definition](https://developer.mozilla.org/en-US/docs/Web/CSS/transform#formal_definition)153