Skip to content

AnimateZoom

Content arriving from the middle of where it will end up. The same arithmetic as AnimateGrow at more than twice the distance and always about the centre, for the one thing on a screen that is meant to interrupt.

tsx
import { AnimateZoom } from 'neba';

<AnimateZoom>
  <Statistic label="Uptime this quarter" value={99.98} unit="%" />
</AnimateZoom>;

Props

PropTypeDefaultDescription
fromnumber0.4The scale it starts from. Above 1 it arrives oversized and settles back, which reads as coming towards the reader
fadebooleantrueFades in as it zooms
staggersharednumber0How 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
durationStepsharednumber0How much longer each successive child takes, in milliseconds. Negative speeds them up down the list, and never past zero
reversesharedbooleanfalseRuns 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
durationsharednumber340How long one run takes, in milliseconds
delaysharednumber0How long before it starts, in milliseconds
easingstringThe easing curve, as CSS writes it. Defaults to the house curve
repeatsharednumber | 'infinite'1How many times it runs
alternatesharedbooleanfalseRuns 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
playbooleanRuns it when trigger is manual. Each false → true starts it over
oncesharedbooleantrueWith trigger="visible", whether it runs only the first time. Off, it runs again on every return
thresholdsharednumber0.2With trigger="visible", how much of the element has to be on screen, from 0 to 1
pausedsharedbooleanfalseHolds the animation where it is
renderuseRender.RenderPropRenders something other than a div (render={<section />}). Base UI's own escape hatch
childrenReactNodeWhat comes forward

Every other <div> attribute passes through to the root. The settings shared by every Animate* are defined in prop conventions.

There is no origin: a zoom anchored to a corner is a grow, and that is AnimateGrow.

Examples

from

The scale it starts at. Well below 1 it comes up out of nothing; above 1 it arrives oversized and settles back, which reads as coming towards the reader rather than up out of the page.

trigger="visible"

The most common use of a zoom is a figure that lands as the reader reaches it. threshold is how much of the element has to be on screen first, from 0 to 1, and once (on by default) is what stops it replaying every time the page scrolls back.

mode

out drops it away again, held at the end.

tsx
<AnimateZoom mode="out" duration={240}>
  <Card title="Dismissed">This card is on its way out.</Card>
</AnimateZoom>

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.
  • A strong zoom over a large area is the most likely effect in this set to bother a reader who is sensitive to motion. Prefer a small from, or a fade, for anything covering much of the viewport.

Released under the MIT License