Transition Group
TransitionGroup React primitive for rendering components over time, with entering, active, and exiting transition states for CSS or JS animation
import { TransitionGroup } from "@plexui/ui/components/Transition";<TransitionGroup> controls when children mount and unmount and wraps them in a container with stateful data attributes for enter/exit transitions. Prefer <Animate>, <AnimateLayout>, or <AnimateLayoutGroup>. Use <TransitionGroup> only for custom or very complex transitions. Children must have a stable key.
Examples
Overview
Timing is driven by enterDuration and exitDuration. No default styles are applied; use the data attributes below in your CSS.
Transition states
No default styles are applied. Use these data attributes in your CSS:
| Attribute | Description |
|---|---|
data-entering | Enter transition is about to start; stays for the full entrance. |
data-entering-active | Enter transition is active. |
data-exiting | Exit transition is about to start; stays for the full exit. |
data-exiting-active | Exit transition is active. |
data-interrupted | Transition was interrupted (e.g. exit then re-mounted before exit finished). |
Initial mount
By default, children do not run enter/exit when <TransitionGroup> first mounts. Use preventInitialTransition= to allow initial enter.
CSS example
.Example {
&[data-entering] { opacity: 0; }
&[data-exiting] { opacity: 1; }
&[data-entering-active],
&[data-exiting][data-interrupted] {
opacity: 1;
box-shadow: 0 0 0 5px green;
transition: opacity 2s ease, box-shadow 2s ease;
}
&[data-exiting-active],
&[data-entering][data-interrupted] {
opacity: 0;
box-shadow: 0 0 0 5px red;
transition: opacity 1s ease, box-shadow 1s ease;
}
}Vue
import { TransitionGroup, PlexTransitionGroup } from "@plexui/vue/components/Transition";Vue's template compiler always resolves <TransitionGroup> to its built-in component, so templates use the PlexTransitionGroup alias (render functions can use either name). Props and data attributes are the same as in React; lifecycle callbacks are listeners such as @enter and @exit-complete.
Reference
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Class applied to the wrapper (receives transition data attributes) |
enterDuration | number | — | Duration in ms for enter transition |
exitDuration | number | — | Duration in ms for exit transition |
preventInitialTransition | boolean | true | When false, children run enter when the group first mounts |
overlay | boolean | false | For overlays: an exiting child is inert, out of the tab order and of hit testing, and with reduced motion it leaves without waiting for exitDuration |