Skip to content

AnimateRotate

Content turning about a point. Two angles rather than one, so the same component covers both a glyph swinging into place and one that spins without ever landing.

tsx
import { AnimateRotate } from 'neba';

<AnimateRotate from={-270}>
  <Icon icon={<StarIcon />} size="xl" color="warning" label="Starred" />
</AnimateRotate>;

Props

PropTypeDefaultDescription
fromnumber-180The angle it starts at, in degrees. Negative is anticlockwise
tonumber0The angle it ends at. Together with from this covers both a turn into place and an endless spin
originstring'center'Which point it turns about: any CSS transform-origin
fadebooleantrueFades in as it turns. Turn it off for a continuous spin
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
durationsharednumber460How 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={<span />}). Base UI's own escape hatch
childrenReactNodeWhat turns

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

Examples

from and to

from alone is an arrival: something swings into place and stops. from and to together with repeat="infinite", easing="linear" and fade={false} is a spin that never lands: a working mark, a decorative glyph. Negative angles turn anticlockwise.

origin

Any CSS transform-origin. Off-centre it becomes a swing rather than a spin, which with alternate is a rock back and forth.

fade

On by default, and the first thing to turn off for anything repeating: a fade that runs on every pass of a spin reads as flickering rather than as turning.

tsx
<AnimateRotate from={0} to={360} repeat="infinite" easing="linear" fade={false}>
  <Icon icon={<GearIcon />} label="Working" />
</AnimateRotate>

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 its to angle.
  • Do not rotate text. A rotated word is resampled along its whole length, which is exactly what the design language's rule against transforms exists to prevent. Rotation is for glyphs.

Released under the MIT License