An entrance that slides elements into place on load or when they scroll into view.
Design
Build
Ship
Installation
Usage
import { Slide, Slides } from '@animate-ui/react/primitives/effects/slide';
export function Hero() {
return (
<>
<Slide direction="up">
<h1>Animated primitives for React</h1>
</Slide>
{/* Staggered: each child starts 100ms after the previous one. */}
<Slides holdDelay={100} direction="up">
<Card />
<Card />
<Card />
</Slides>
</>
);
}With asChild, the animation is applied to your element instead of a wrapping div.
Animation
- The element travels
offsetpixels (100 by default) into place on a spring (stiffness 200, damping 20), overshooting by about 4% before it settles. It moves withx/y, a hardware-accelerated transform. directionis the direction it moves in:upstarts below its place.- Under reduced motion, it doesn't travel: it fades in instead.
inViewwaits for the element to scroll into view, once by default.<AnimateUIProvider tempo>paces the default spring.
API Reference
Slide
| Prop | Type | Default |
|---|---|---|
asChild? | boolean | false |
direction? | 'up' | 'down' | 'left' | 'right' | 'up' |
offset? | number | 100 |
delay? | number | 0 |
transition? | Transition | { type: 'spring', stiffness: 200, damping: 20 } |
inView? | boolean | false |
inViewOnce? | boolean | true |
inViewMargin? | string | '0px' |
...props? | HTMLMotionProps<'div'> | - |
Slides
Wraps each child in a Slide, delaying each one a little more than the previous.
| Prop | Type | Default |
|---|---|---|
children | React.ReactElement | React.ReactElement[] | - |
holdDelay? | number | 0 |
...props? | SlideProps | - |