Skip to content

AnimateFade

Content arriving or leaving on opacity alone. The plainest effect in the set and the one to reach for first: nothing moves, so nothing reflows and no text is resampled.

tsx
import { AnimateFade } from 'neba';

<AnimateFade>
  <Card title="Deployment finished">Two services restarted, no errors.</Card>
</AnimateFade>;

Props

PropTypeDefaultDescription
fromnumber0The opacity it starts from, between 0 and 1
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
durationsharednumber320How 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 arrives or leaves

Every other <div> attribute passes through to the root.

The settings shared by every Animate* (duration, delay, easing, repeat, alternate, trigger, play, once, threshold, paused) mean the same thing on all of them, and are defined in prop conventions.

Examples

duration and delay

Both are milliseconds. A delay is what turns a set of fades into a sequence, and it is what AnimateAppear does for you when the things being delayed are a list.

trigger

mount is the default and needs nothing from you. visible waits until the element is scrolled into view (once, unless once is off), and threshold is how much of it has to be on screen. hover runs while the pointer is on it, restarting on each entry, and keyboard focus counts as a pointer. manual runs nothing until play says so, and every falsetrue starts it over.

mode

out is the same animation run backwards, and it is held there: a faded-out element stays faded out rather than snapping back when the animation ends. With alternate it returns instead of jumping, which is what makes a repeating fade a pulse.

from

The opacity the fade starts at, between 0 and 1. Raise it for content that should never be completely gone: a dimming rather than a disappearance.

tsx
<AnimateFade from={0.4}>
  <Chip>Draft</Chip>
</AnimateFade>

stagger, durationStep and reverse

stagger is how long after one child the next one starts, in milliseconds. At 0 (the default), the box itself is what fades, and the children are left alone. Above it the effect moves onto each child in turn and nothing is written on the box, so a list of five arrives one row at a time.

durationStep adds that many milliseconds to each successive child's duration; a negative value speeds them up down the list, and a duration never goes below zero. reverse runs the children last-to-first: only the order reverses, each child still plays forwards.

The step is per child, so what you pass matters: five children are five steps, and one child holding five things is one step. Grouping is how part of a list opts out.

Accessibility

  • A reduced-motion preference switches the animation off entirely and the content is simply there. It is never left invisible.
  • The wrapper adds no role and no name; whatever is inside keeps its own.

Released under the MIT License