<TransitionGroup> component provides transition effects for multiple elements or components in a list. Unlike <Transition>, it renders an actual element and requires children to be keyed.
Basic Usage
Props
<TransitionGroup> accepts all the same props as <Transition> except mode, plus two additional props:
tag
- Type:
string - Default:
Fragment(renders no wrapper element)
<TransitionGroup> renders a fragment (no wrapper element).
moveClass
- Type:
string
${name}-move where name is the transition name.
Inherited Props from Transition
name
- Type:
string - Default:
'v'
css
- Type:
boolean - Default:
true
type
- Type:
'transition' | 'animation'
duration
- Type:
number | { enter: number; leave: number }
appear
- Type:
boolean - Default:
false
Custom Transition Classes
All custom class props from<Transition>:
- enterFromClass -
string - enterActiveClass -
string - enterToClass -
string - leaveFromClass -
string - leaveActiveClass -
string - leaveToClass -
string - appearFromClass -
string - appearActiveClass -
string - appearToClass -
string
JavaScript Hooks
All hooks from<Transition> are supported:
- onBeforeEnter -
(el: Element) => void - onEnter -
(el: Element, done: () => void) => void - onAfterEnter -
(el: Element) => void - onEnterCancelled -
(el: Element) => void - onBeforeLeave -
(el: Element) => void - onLeave -
(el: Element, done: () => void) => void - onAfterLeave -
(el: Element) => void - onLeaveCancelled -
(el: Element) => void - onBeforeAppear -
(el: Element) => void - onAppear -
(el: Element, done: () => void) => void - onAfterAppear -
(el: Element) => void - onAppearCancelled -
(el: Element) => void
Move Transitions
The<TransitionGroup> component supports move transitions via the FLIP technique. When items change position, a move class is applied to smoothly transition them to their new positions.
Move Class
The move class (defaults to${name}-move) is applied to elements that are changing position:
The move transition uses the CSS
transform property. Make sure leaving elements are removed from the layout flow (e.g., with position: absolute) so that the move animation can be calculated correctly.Key Requirement
Complete Example
Differences from <Transition>
- Renders an element:
<TransitionGroup>renders a real DOM element (or fragment), while<Transition>does not. - No
modeprop: Themodeprop is not supported. - Children must be keyed: All children must have unique
keyattributes. - Move transitions: Supports smooth position transitions via the move class.
Source Reference
- Package:
@vue/runtime-dom - Implementation:
/packages/runtime-dom/src/components/TransitionGroup.ts:61-175 - Props Interface:
/packages/runtime-dom/src/components/TransitionGroup.ts:42-45
See Also
- Transition - For single element transitions
- Guide: TransitionGroup - Detailed guide