An entrance that fades elements in on load or when they scroll into view.
Design
Build
Ship
Installation
Usage
import { Fade, Fades } from '@animate-ui/react/primitives/effects/fade';
export function Hero() {
return (
<>
<Fade>
<h1>Animated primitives for React</h1>
</Fade>
{/* Staggered: each child starts 100ms after the previous one. */}
<Fades holdDelay={100}>
<Card />
<Card />
<Card />
</Fades>
</>
);
}With asChild, the animation is applied to your element instead of a wrapping div.
Animation
- The element fades from
initialOpacitytoopacityon a spring (stiffness 200, damping 20): about 250ms. - Only opacity animates, so it stays the same under reduced motion.
inViewwaits for the element to scroll into view, once by default.<AnimateUIProvider tempo>paces the default spring.
API Reference
Fade
| Prop | Type | Default |
|---|---|---|
asChild? | boolean | false |
initialOpacity? | number | 0 |
opacity? | number | 1 |
delay? | number | 0 |
transition? | Transition | { type: 'spring', stiffness: 200, damping: 20 } |
inView? | boolean | false |
inViewOnce? | boolean | true |
inViewMargin? | string | '0px' |
...props? | HTMLMotionProps<'div'> | - |
Fades
Wraps each child in a Fade, delaying each one a little more than the previous.
| Prop | Type | Default |
|---|---|---|
children | React.ReactElement | React.ReactElement[] | - |
holdDelay? | number | 0 |
...props? | FadeProps | - |