An entrance that fades elements in on load or when they scroll into view.
Installation
Usage
<script setup lang="ts">
import { Fade, Fades } from '@animate-ui/vue/primitives/effects/fade';
import Card from './Card.vue';
</script>
<template>
<Fade>
<h1>Animated primitives for Vue</h1>
</Fade>
<!-- Staggered: each child starts 100ms after the previous one. -->
<Fades :hold-delay="100">
<Card />
<Card />
<Card />
</Fades>
</template>With as-child, the animation is applied to your element instead of a wrapping div.
Animation
- The element fades from
initial-opacitytoopacityon a spring (stiffness 200, damping 20): about 250ms. - Only opacity animates, so it stays the same under reduced motion.
in-viewwaits for the element to scroll into view, once by default.<AnimateUIProvider :tempo>paces the default spring.
API Reference
Fade
| Prop | Type | Default |
|---|---|---|
as-child? | boolean | false |
initial-opacity? | number | 0 |
opacity? | number | 1 |
delay? | number | 0 |
transition? | Transition | { type: 'spring', stiffness: 200, damping: 20 } |
in-view? | boolean | false |
in-view-once? | boolean | true |
in-view-margin? | string | '0px' |
...props? | HTMLMotionProps<'div'> | - |
Fades
Wraps each child in a Fade, delaying each one a little more than the previous.
| Prop | Type | Default |
|---|---|---|
#default | slot | - |
hold-delay? | number | 0 |
...props? | FadeProps | - |