Animate Layout
AnimateLayout React primitive for smoothly animating width and height changes, such as accordion expansion, growing buttons, and dynamic content panels
import { AnimateLayout } from "@plexui/ui/components/Transition";Use when transitions should affect the layout of surrounding DOM nodes (e.g. expanding/collapsing content).
Gotchas
<AnimateLayout>provides a wrapping element, whichclassNameand layout transition properties are applied to.- Avoid box model properties on
className, likemargin,padding,border. These are additive to theheight: 0empty state and cannot be properly animated. - Avoid
box-shadowonclassName, as it will be visible during the empty state. - Use padding on children (via
transitionClassName) instead of margin on the wrapper.
Examples
Overview
<AnimateLayout> is an abstraction around <TransitionGroup> that also animates height and width of transitions.
It supports the same props as <Animate> except transitionPosition, plus dimension, hideOverflow, itemAnchor, and layoutEnter, layoutExit and layoutMove for layout timing.
Height
By default, animates the height of the component as it enters and exits.
Width
Use dimension="width" to animate width.
Accordion
Wrap accordion content with <AnimateLayout> for smooth height animation.
Talk button
Animate width with consistent height. Use transitionClassName to match the button's flex structure.
Vue
import { AnimateLayout } from "@plexui/vue/components/Transition";Props are the same as in React, in kebab-case (transition-class-name). Children come from the default slot and keep a stable key.
Reference
| Prop | Type | Default | Description |
|---|---|---|---|
as | "span" | "div" | "span" | Tag used for the wrapper and item elements |
className | string | — | Class applied to the wrapper element |
transitionClassName | string | — | Class applied to the inner TransitionGroup; use for padding on children |
dimension | "height" | "width" | "height" | Which property to animate during transitions |
enter | TransitionDefinition | — | Enter transition (opacity, x, y, scale, etc.) |
exit | TransitionDefinition | — | Exit transition |
initial | InitialTransitionDefinition | — | State before enter |
layoutEnter | LayoutTransitionDefinition | — | Timing for layout enter (duration, delay, timingFunction) |
layoutExit | LayoutTransitionDefinition | — | Timing for layout exit |
layoutMove | LayoutTransitionDefinition | — | Timing for layout move |
hideOverflow | boolean | false | Apply overflow: hidden to the wrapper |
itemAnchor | "start" | "end" | "start" | Which side of the container items pin to during enter/exit |
preventInitialTransition | boolean | true | When false, children run enter on initial mount |
insertMethod | "append" | "prepend" | "append" | Whether new children are added after (append) or before (prepend) the existing ones |
forceCompositeLayer | boolean | false | Applies will-change; use with caution |