Skip to content

Vue scroll animations

Use @awesome-reveal/vue to add scroll animations to a Vue app. An element fades and slides in when it scrolls into view. The package does not link an animation to the scroll position, as a parallax effect or a scroll progress bar does.

Terminal window
pnpm add @awesome-reveal/vue

For the supported Vue versions, see Requirements.

Wrap the element in Reveal:

<script setup>
import { Reveal } from "@awesome-reveal/vue";
</script>
<template>
<Reveal as="section" from="left">
<h1>Scroll animations in Vue</h1>
<p>The section fades in from the left.</p>
</Reveal>
</template>

Reveal renders an element around its default slot. as sets its tag, and from sets the entrance. To fade, zoom, rotate or blur the element in, set a start state.

Cascade reveals its direct children one after the other:

<script setup>
import { Cascade } from "@awesome-reveal/vue";
</script>
<template>
<Cascade as="ul" :from="{ opacity: 0, y: 16 }" :interval="120">
<li>Fast</li>
<li>Small</li>
<li>Accessible</li>
</Cascade>
</template>

For a long list or a tall grid, see Animate a list.

v-reveal and v-cascade reveal an element that you render, with no wrapper element. In <script setup>, import vReveal to use v-reveal in the template:

<script setup>
import { vReveal } from "@awesome-reveal/vue";
</script>
<template>
<article v-reveal="{ from: { opacity: 0, scale: 0.95 } }" class="card">
A card
</article>
</template>

To use the directives with no import, register them for all components.

To play the entrance when your state changes, such as when a panel opens, give when. To run code when the element reveals, listen to the reveal event of Reveal and Cascade, or give onReveal to v-reveal.

To prevent a flash of the content before hydration, see Server rendering.