AnimateGrow
Content unfolding from a point. It starts close to its final size and can be anchored to any edge, so it reads as something opening out of the thing next to it.
import { AnimateGrow } from 'neba';
<AnimateGrow origin="top">
<Card title="Filters">Three of nine applied.</Card>
</AnimateGrow>;Props
| Prop | Type | Default | Description |
|---|---|---|---|
| from | number | 0.8 | The scale it starts from, as a multiple of its final size. Above 1 it settles down onto the page |
| origin | string | 'center' | Which point stays put while the rest moves: any CSS transform-origin |
| fade | boolean | true | Fades in as it grows |
| staggershared | number | 0 | How long after one child the next one starts, in milliseconds. 0 animates the box itself; anything above it moves the effect onto each child in turn |
| durationStepshared | number | 0 | How much longer each successive child takes, in milliseconds. Negative speeds them up down the list, and never past zero |
| reverseshared | boolean | false | Runs the children from the last to the first. Only the order reverses |
| modeshared | 'in' | 'out' | 'in' | Whether the content arrives or leaves. out is the same animation run backwards, and it is held there |
| durationshared | number | 340 | How long one run takes, in milliseconds |
| delayshared | number | 0 | How long before it starts, in milliseconds |
| easing | string | — | The easing curve, as CSS writes it. Defaults to the house curve |
| repeatshared | number | 'infinite' | 1 | How many times it runs |
| alternateshared | boolean | false | Runs every other pass backwards, so a repeat returns instead of jumping |
| triggershared | 'mount' | 'visible' | 'hover' | 'manual' | 'mount' | What starts it. visible is on scrolling into view, hover is under the pointer (focus counts), manual is whatever play says |
| play | boolean | — | Runs it when trigger is manual. Each false → true starts it over |
| onceshared | boolean | true | With trigger="visible", whether it runs only the first time. Off, it runs again on every return |
| thresholdshared | number | 0.2 | With trigger="visible", how much of the element has to be on screen, from 0 to 1 |
| pausedshared | boolean | false | Holds the animation where it is |
| render | useRender.RenderProp | — | Renders something other than a div (render={<li />}). Base UI's own escape hatch |
| children | ReactNode | — | What unfolds |
Every other <div> attribute passes through to the root. The settings shared by every Animate* are defined in prop conventions.
Examples
origin
Any CSS transform-origin: the point that stays put while the rest moves. top unfolds downwards, bottom left out of a corner, and the default center grows evenly in every direction. It is the prop that decides what the growth appears to be coming out of.
from and fade
from is the scale it starts at, as a multiple of its final size. Below 1 it opens out; above 1 it arrives oversized and settles down onto the page. fade is the opacity ramp that comes with it, and turning it off is right for something already on screen that is only changing size.
mode
out folds it away again: the same animation backwards, held at the end.
<AnimateGrow mode="out" origin="top">
<Card title="Filters">Three of nine applied.</Card>
</AnimateGrow>stagger
stagger, durationStep and reverse hand the effect to the children one at a time instead of running it on the box. They work the same way here as on AnimateFade, where they are set out in full.
Accessibility
- A reduced-motion preference switches the animation off entirely and the content is simply there, at full size.
- Scale is applied with the standalone
scaleproperty rather than thetransformshorthand, so a transform of your own on the same element survives.