# Svelte reveal API: components and attachments

> API reference of @awesome-reveal/svelte: the Reveal and Cascade components, the reveal and cascade attachments, the children snippet, the as prop and types.

`@awesome-reveal/svelte` exports two components and two attachments. They take the same [options](/reference/options/), as props or as a function that returns an object. For the supported versions, see [Requirements](/getting-started/#requirements).

```js
import { Cascade, Reveal, cascade, reveal } from "@awesome-reveal/svelte";
```

## Reveal

Renders an element around its children, and reveals the element when it enters the viewport.

```svelte
<Reveal as="section" from="left" class="hero">Hello</Reveal>
```

* **Props**: `as`, `from`, `keyframes`, `duration`, `delay`, `threshold`, `when` and `onReveal`. See [Options](/reference/options/).
* **Other attributes**: the component gives them to the rendered element, for example `class`, `id` and `aria-*`. It also gives the attachments that you put on the component to the element.
* **`children` snippet**: the component gives it `revealed`, which is `true` after the reveal. See [Read the revealed state](/guides/reveal-events/#read-the-revealed-state).
* **`as` changes**: the component keeps its reveal.

`as` accepts an HTML tag or a custom element, such as `my-card`. It does not accept these tags:

* a void tag, such as `img` or `input`, because the component renders children
* a tag whose children cannot hydrate, such as `textarea`, `title`, `template` or `iframe`

## Cascade

Renders an element around its children. When the element enters the viewport, it reveals the direct element children one after the other. See [Animate a list](/guides/lists/).

`Cascade` accepts the props of `Reveal`, and [`interval`](/reference/options/#interval). It gives the same `children` snippet. `onReveal` gets the container.

## reveal

Returns an [attachment](https://svelte.dev/docs/svelte/@attach) that reveals the element.

```svelte
<article {@attach reveal(() => ({ from: "left", onReveal: entered }))}>
  A card
</article>
```

* **Argument**: a function that returns the options of `Reveal`, except `as`. With no argument, the attachment uses the default options.
* **Updates**: the attachment reads the function in an effect. A change of the state that the function reads updates the options of the same reveal. A change of [`when`](/reference/options/#when) or `threshold` applies immediately, and the other options apply at the next reveal.
* **Server rendering**: the attachment does not run on the server, so the server HTML shows the element. See [SvelteKit](/frameworks/sveltekit/#components-and-attachments).
* **New element**: the reveal belongs to the element. A new element, such as one in a `{#key}` block, starts a new reveal.

An attachment with fixed options can be in a module and serve many elements:

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

export const fadeIn = reveal(() => ({ from: { opacity: 0 }, duration: 400 }));
```

## cascade

Returns an attachment that reveals the direct element children of the element. Its function accepts the options of `reveal`, and [`interval`](/reference/options/#interval).

## Stylesheet

The package imports its stylesheet, on the server and in the browser. It also exports the stylesheet as `@awesome-reveal/svelte/reveal.css`.

## Types

| Type             | Description                                             |
| ---------------- | ------------------------------------------------------- |
| `RevealProps`    | The props of `Reveal`.                                  |
| `CascadeProps`   | The props of `Cascade`.                                 |
| `RevealOptions`  | The options that the function of `reveal` returns.      |
| `CascadeOptions` | The options that the function of `cascade` returns.     |
| `Side`           | The sides of [`from`](/reference/options/#from).        |
| `StartState`     | The [start state](/guides/entrances/) object of `from`. |
