# Svelte scroll animations

> Add scroll animations to Svelte 5: fade and slide elements in with Reveal, stagger a list with Cascade, and reveal your own elements with the reveal attachment.

Use `@awesome-reveal/svelte` to add scroll animations to a Svelte 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

```shell
pnpm add @awesome-reveal/svelte
```

The package is a release candidate. For the supported Svelte versions, see [Requirements](/getting-started/#requirements).

## Reveal an element on scroll

Wrap the element in `Reveal`:

```svelte
<script>
  import { Reveal } from "@awesome-reveal/svelte";
</script>

<Reveal as="section" from="left">
  <h1>Scroll animations in Svelte</h1>
  <p>The section fades in from the left.</p>
</Reveal>
```

`Reveal` renders an element around its children. [`as`](/reference/options/#as) sets its tag, and [`from`](/guides/entrances/) sets the entrance. To fade, zoom, rotate or blur the element in, set a [start state](/guides/entrances/#zoom-rotate-and-blur-with-a-start-state).

## Stagger a list with Cascade

`Cascade` reveals its direct children one after the other:

```svelte
<script>
  import { Cascade } from "@awesome-reveal/svelte";
</script>

<Cascade as="ul" from={{ opacity: 0, y: 16 }} interval={120}>
  <li>Fast</li>
  <li>Small</li>
  <li>Accessible</li>
</Cascade>
```

For a long list or a tall grid, see [Animate a list](/guides/lists/#reveal-a-long-list-or-a-tall-grid).

## Reveal your own element with an attachment

The `reveal` and `cascade` [attachments](https://svelte.dev/docs/svelte/@attach) reveal an element that you render, with no wrapper element. Give the options as a function that returns them:

```svelte
<script>
  import { reveal } from "@awesome-reveal/svelte";
</script>

<article
  {@attach reveal(() => ({ from: { opacity: 0, scale: 0.95 } }))}
  class="card"
>
  A card
</article>
```

For the options function, see [Svelte API](/reference/svelte/#reveal-1).

Attachments run only in the browser. For server-rendered content, use `Reveal` and `Cascade`. See [SvelteKit](/frameworks/sveltekit/#components-and-attachments).

## Control the reveal from state

To play the entrance when your state changes, such as when a panel opens, give [`when`](/guides/manual-control/). To run code when the element reveals, give [`onReveal`](/guides/reveal-events/).

## Server rendering

To prevent a flash of the content before hydration, see [Server rendering](/concepts/server-rendering/).

* For SvelteKit, see [SvelteKit scroll animations](/frameworks/sveltekit/).
* For a Svelte island in Astro, see [React, Vue and Svelte scroll animations in Astro](/frameworks/react-vue-astro/).

## Next steps

* [Use your own keyframes](/guides/keyframes/): give native Web Animations keyframes.
* [Change the timing](/guides/timing/): set the duration, the delay and the threshold.
* [Svelte API](/reference/svelte/): all the components, attachments and types.
