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.
Install the package
Section titled “Install the package”pnpm add @awesome-reveal/vueFor the supported Vue versions, see Requirements.
Reveal an element on scroll
Section titled “Reveal an element on scroll”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.
Stagger a list with Cascade
Section titled “Stagger a list with Cascade”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.
Reveal your own element with a directive
Section titled “Reveal your own element with a directive”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.
Control the reveal from state
Section titled “Control the reveal from state”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.
Server rendering
Section titled “Server rendering”To prevent a flash of the content before hydration, see Server rendering.
- For Nuxt, see Nuxt and Vue SSR scroll animations.
- For a Vue island in Astro, see React and Vue scroll animations in Astro.
Next steps
Section titled “Next steps”- Use your own keyframes: give native Web Animations keyframes.
- Change the timing: set the duration, the delay and the threshold.
- Vue API: all the components, directives and types.