# Background effects
> Background effects for the hero: the catalogue in docara.json, choosing an effect, theme, the pause button, reduced motion, CSP and build errors.
Source:
A background effect is an animation under the text of the
[hero](https://docara.io/en/components/layout/hero/): a starry sky, a grid, waves and others. The
effect replaces a background image, so nothing needs to be redrawn for the
site's other languages. The text over the effect stays ordinary page text:
it can be selected, translated and found by search.
SIMAI Framework draws the effects and takes them from the SIMAI effect
catalogue. Docara only records in the Hero which effect is needed and checks
the settings at build time.
## How to add an effect
### 1. Connect the catalogue
The catalogue is set once for the whole site in `docara.json`:
```json
{
"effects": {
"catalogue": "https://cdn.jsdelivr.net/gh/simai/ui-effects@264cb2efc182fd7af6bc273bdcc3006f1588af18/"
}
}
```
`catalogue` is the catalogue address. Pin it to a specific commit, not to a
branch (`@main`): otherwise the effects on your site may change without your
knowledge. This site connects the catalogue at the address above.
Two more fields are optional:
| Field | Sets |
| --- | --- |
| `index` | The path to the effect list inside the catalogue. The default is `catalogue/index.json`. |
| `index_sha256` | The SHA-256 checksum of that list. If it is set, the browser does not run effects from a changed list. |
### 2. Choose an effect
All the catalogue's effects, how they look and their settings are collected
on [effects.simai.io](https://effects.simai.io/). You can also tune the
settings there and copy them. Docara does not download the catalogue during
the build, so the full list of effects is kept on that site, not here.
Note the effect's identifier: lowercase Latin letters, digits and hyphens,
for example `constellation-net` or `aurora-curtain`.
### 3. Set the effect in the Hero
:::example {label="Constellations"}
```markdown
:::hero {layout=centered effect=constellation-net}
# Documentation that is easy to read
The effect is drawn under the text and does not get in the way of reading.
:::
```
:::
The [home page](https://docara.io/en/) of this site opens with another effect, "Chladni
figures" (`chladni`), and its Hero has a large `padding=2xl`. An effect works
with any Hero variant, but not with a background image: set either `effect`
or `media=background`.
## Parameters
| Parameter | Value |
| --- | --- |
| `effect` | An effect identifier from the catalogue, 2 to 41 characters, or the `https` address of its `effect.json` file inside the catalogue. |
| `effect_theme` | The light or dark version of the effect: `auto` follows the page (the default), `dark` or `light`. |
| `effect_settings` | The effect settings — a JSON object in single quotes, for example `'{"speed": 80}'`. effects.simai.io shows which settings an effect has. |
```markdown
:::hero {layout=centered effect=aurora-curtain effect_theme=dark effect_settings='{"speed": 80}'}
# A dark hero
The effect is always drawn in its dark version, and the text becomes light.
:::
```
### Effect theme
With `effect_theme=auto` the effect follows the page theme: when the reader
switches the theme, the effect switches too. With `dark` or `light` the
effect always stays in one version, and the Hero text adapts to it. While
the effect loads, the Hero already has the background and text colour of
that theme, so the text is readable at once.
If the effect lacks the needed version, for example it only has a dark one
and the page is light, the effect is not shown, and the Hero looks as it
would without an effect.
## More effects
Below are three more effects from this site's catalogue. Each has a light
and a dark version: switch the site theme and the effect changes with it.
An effect moves only while it is visible on the screen and is not drawn at
all in a hidden tab.
:::example {label="Light conduits"}
```markdown
:::hero {layout=compact effect=hex-conduits}
# Light conduits
Light pulses run across a hexagonal grid.
:::
```
:::
:::example {label="Glyph tide"}
```markdown
:::hero {layout=compact effect=glyph-tide effect_settings='{"charset": "binary"}'}
# Glyph tide
A wave of characters. The `charset` setting picks binary characters instead
of hexadecimal ones.
:::
```
:::
:::example {label="Contour lines"}
```markdown
:::hero {layout=compact effect=contour-map}
# Contour lines
Elevation lines, as on a topographic map.
:::
```
:::
All the catalogue's effects and their settings are shown on
[effects.simai.io](https://effects.simai.io/).
## A scene over the first screen
`layout=stage` turns a Hero into a live scene about four fifths of the window
high: 82 % of the screen height, but no less than 576 and no more than 832 px.
The text stands over the scene, and the scene is the effect, so without
`effect` the build stops, and such a Hero takes no image.
:::example {label="A scene over the first screen"}
```markdown
:::hero {layout=stage effect=constellation-net effect_theme=dark}
# Documentation that is easy to read
Ready parts from tokens to Smart Components. Straight from a CDN, no npm, no build step.
[Start in 5 minutes](/en/start/quick-start/)
:::
```
:::
How a scene differs from an ordinary Hero with an effect:
- **The scene answers the reader.** Hover, clicks, press-and-hold, Ctrl and
the wheel, and touch go to the effect. The text lets them through; only
links and buttons take them.
- **The text reads on any scene.** A scrim in the colour of the scene's
surface covers it from the text side: from the left on a wide screen (from
the right in right-to-left languages), from the top on a phone.
- **The scene shows on a phone too.** There the text stands in the upper part,
under the scrim.
- **The title is larger.** It is the SIMAI Framework display step: size 11 on a
wide screen and 9 on a phone.
- **The scene can be skipped from the keyboard.** The first Tab shows the link
"Skip the scene"; it leads to the block after the Hero. Its label comes from
the `effects.skip` string of `lang.json`.
`effect_theme` sets the scene's theme: `dark`, for example, keeps it a night
panel in both page themes. The scene takes the language and writing direction
from the page. Pause, the still frame for reduced motion and the stop off
screen work as for any effect.
## Pause and reduced motion
While the effect moves, the bottom right corner of the Hero (the left one in
right-to-left languages) has a "Pause background animation" button. It does
not cover the text or the image, even on a phone. Pressing it again starts
the effect again. The choice is remembered in the reader's browser for the
whole site.
The button fits into the Hero's bottom padding. With `padding=2xl` the Hero
height does not change. With `lg` and `xl` the bottom padding of a Hero with
an effect becomes slightly larger: 52 px on a narrow screen and 56 px from
960 px.
If the reader's system has reduced motion turned on, the effect shows a
single still frame, and the button does not appear.
The button labels come from the `effects.pause` and `effects.play` strings
of the `lang.json` file. They are built in for English and Russian; for
another language set them as described in the
[lang.json interface labels](https://docara.io/en/reference/lang-json/) reference.
## Narrow screens
Below 704 px the Hero is one column, and its text spans the whole width. The
effect would be drawn under the heading, the text and the buttons, so it is
not shown there: the Hero keeps the background it has before the effect
starts, the pause button does not appear, and the effect itself is paused.
From 704 px the effect is visible again.
## Where the effect will not be drawn
A site with an effect stays static, but the effect loads from the catalogue
in the reader's browser. The effect does not appear, and the Hero looks as
it would without it, if:
- the browser cannot download the catalogue files, for example the reader
is offline;
- the effect file does not match the checksum in the catalogue list;
- the effect has no version for the needed theme;
- the site is built with a SIMAI Framework version without effect support
(earlier than `ui-08c07b3e938a`). Docara ships with a suitable version.
Why the effect was not drawn is visible in the browser's developer tools:
the Hero section's `data-sf-effect-state` attribute is `refused` or
`failed`, and `data-sf-effect-reason` holds the reason, for example
`fetch-failed` or `integrity`.
## Content-Security-Policy
Docara does not set a Content-Security-Policy header. If your hosting adds
one, allow in it what the effect needs:
| Directive | What to allow | Why |
| --- | --- | --- |
| `connect-src` | the catalogue address, for example `https://cdn.jsdelivr.net` | the Framework downloads the effect list and the effect files and checks their checksums |
| `script-src` | `blob:` | the verified effect file runs from the browser's memory instead of being downloaded a second time |
| `script-src` | the page's inline scripts (`'unsafe-inline'` or their hashes) | a short `