# Staggered list animations with Cascade

> Animate the items of a list, a grid or the words of a heading one after the other with Cascade and the interval option, and reveal long lists item by item.

A cascade reveals the children of a container one after the other, when the container enters the viewport. Each package has a cascade API:

* React: `Cascade` and `useCascade`.
* Vue: `Cascade` and `v-cascade`.
* Astro: `Cascade`.
* JavaScript: `cascade()`.

The cascade APIs accept all the options of a reveal, and also [`interval`](/reference/options/#interval).

## Reveal the items one after the other

Put the items in a cascade. Select an interval to see the effect:

Only the direct element children animate. Text and deeper descendants do not animate. In React, Vue and Astro, a child with [`display: contents`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/display#contents) shows immediately.

## Change the interval

`interval` sets the time between the entrances of two children, in milliseconds. The default is 80. The child at position `index` waits `delay + index * interval`. So [`delay`](/guides/timing/#delay-the-entrance) moves the start of the whole sequence.

A negative interval gives negative delays. Each later child then starts further into its entrance.

## Reveal the words of a heading

A cascade does not split text. To reveal each word, wrap each word in an element:

* React

  ```jsx
  import { Cascade } from "@awesome-reveal/react";

  export function HeadingWords() {
    return (
      <Cascade as="h2" className="words" interval={60}>
        <span>Reveal</span> <span>each</span> <span>word</span>
      </Cascade>
    );
  }
  ```

* Vue

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

  <template>
    <Cascade as="h2" class="words" :interval="60">
      <span>Reveal</span> <span>each</span> <span>word</span>
    </Cascade>
  </template>
  ```

* Astro

  ```astro
  ---
  import { Cascade } from "@awesome-reveal/astro";
  ---

  <Cascade as="h2" class="words" interval={60}>
    <span>Reveal</span> <span>each</span> <span>word</span>
  </Cascade>
  ```

* JavaScript

  ```js
  import { cascade } from "@awesome-reveal/core";

  cascade("h2.words", { interval: 60 });
  ```

The entrance moves the element with a transform, and an [inline element cannot have a transform](https://www.w3.org/TR/css-transforms-1/#transformable-element). So give the words `display: inline-block`. Select `inline` to see the words fade in with no movement:

## Reveal a long list or a tall grid

A cascade schedules all its children at the same time. In a long list, or in a grid that is taller than the viewport, the last children start late or out of view. Reveal each item instead:

* React

  ```jsx
  import { Reveal } from "@awesome-reveal/react";

  export function PostList({ posts }) {
    return (
      <ul className="posts">
        {posts.map((post) => (
          <Reveal as="li" key={post.id}>
            {post.title}
          </Reveal>
        ))}
      </ul>
    );
  }
  ```

* Vue

  ```vue
  <script setup>
  import { vReveal } from "@awesome-reveal/vue";

  defineProps({ posts: { type: Array, required: true } });
  </script>

  <template>
    <ul class="posts">
      <li v-for="post in posts" :key="post.id" v-reveal>{{ post.title }}</li>
    </ul>
  </template>
  ```

* Astro

  ```astro
  ---
  import { Reveal } from "@awesome-reveal/astro";

  interface Props {
    posts: { id: string; title: string }[];
  }

  const { posts } = Astro.props;
  ---

  <ul class="posts">
    {posts.map((post) => (
      <li>
        <Reveal>{post.title}</Reveal>
      </li>
    ))}
  </ul>
  ```

* JavaScript

  ```js
  import { reveal } from "@awesome-reveal/core";

  reveal("ul.posts > li");
  ```

Also reveal each item of a virtualized list.

## Things to know

* **Add the children before the reveal.** In React, Vue and Astro, the cascade reads its children when it reveals. A child that you add after the reveal shows with no animation. For JavaScript, see [Targets](/reference/javascript/#targets).
* **Do not put a reveal directly inside a cascade.** In React and Vue, the two entrances combine on the same element. In Astro, the host of a nested `Reveal` has `display: contents`, so the cascade does not animate it, and the nested `Reveal` plays only its own entrance.
* **Wrap an Astro island in an element.** An [island](https://docs.astro.build/en/concepts/islands/) has `display: contents`, so the cascade does not animate it.
* **A Vue [`<TransitionGroup>`](https://vuejs.org/guide/built-ins/transition-group.html) adds its own animations.** As a direct child of a cascade, it animates the children too.
* **A React fragment gives one child for each element.** A component that returns a [fragment](https://react.dev/reference/react/Fragment) gives one cascade child for each element of the fragment.
* **The reveal event comes from the container.** [`onReveal` and the `reveal` event](/guides/reveal-events/#run-code-when-the-reveal-starts) get the container, not each child.
