LayoutGroup
motion
components with a layout
prop will detect and animate layout changes every time they commit a React re-render, or their layoutDependency
prop changes.
LayoutGroup
is used to group components that might not render together but do affect each-other's state.
Usage
Take these accordion items that each handle their own state:
If we arrange these next to each other in an Accordion
, when their state updates, their siblings have no way of knowing:
This can be fixed by grouping both components with LayoutGroup
:
Namespace layoutId
Components expecting to perform shared layout animations are provided a layoutId
prop.
In this following example, each Tab
renders an element with the layoutId="underline"
prop.
layoutId
is global across your site. So to render multiple TabRow
s we want to group them with LayoutGroup
and id
prop:
Motion is open source. Sponsorships keep the project sustainable.
Every sponsor receives access to our private Discord, and an exclusive mobile and desktop wallpaper pack.