Skip to content

AnimateSlide

Content travelling in from one edge. The default distance is the element's own size, so it starts exactly out of frame and is never half drawn somewhere it does not belong.

tsx
import { AnimateSlide } from 'neba';

<div className="overflow-hidden">
  <AnimateSlide from="left">
    <Alert color="success" title="Invitation sent" />
  </AnimateSlide>
</div>;

Props

PropTypeDefaultDescription
fromshared'top' | 'right' | 'bottom' | 'left''bottom'Which edge it travels from. Physical, as NebaSide is everywhere
distancenumber | string'100%'How far it travels: a CSS length, or a number in pixels. '100%' is the element's own size
fadebooleantrueFades in as it slides
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
durationsharednumber380How 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={<aside />}). Base UI's own escape hatch
childrenReactNodeWhat travels in

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

Examples

from

Which edge it travels from: top, right, bottom or left. Physical rather than logical, as NebaSide is everywhere in the library: a panel sliding down from the top comes from the top in every writing direction.

Put it in a box with overflow: hidden and the effect is a panel appearing from behind that box's edge.

distance

A CSS length or a number in pixels. '100%' (the default) is the element's own width or height. A short distance is a nudge rather than an entrance; for a whole list of those, one after another, use AnimateAppear.

mode

out sends it back the way it came, held off screen at the end.

tsx
<AnimateSlide mode="out" from="right">
  <Toolbar>…</Toolbar>
</AnimateSlide>

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, in place.
  • The element is moved with translate, so nothing on the page reflows while it runs and no layout under it changes.

Released under the MIT License