# <lottie>

Plays a Lottie vector animation from a JSON file; taps and media commands control it.

Category: Media. Also written `<animation>`.

```ham
<column style="gap-8 items-center w-full">
    <lottie id="logo"
            src="https://hypeapps.dev/gallery/assets/loader.json"
            width="160"
            height="160"
            repeat="true"/>
    <text style="muted">Loading your apps…</text>
</column>
```

How Hype Apps draws it on a phone: [light](https://hypeapps.dev/img/tags/lottie-light.webp), [dark](https://hypeapps.dev/img/tags/lottie-dark.webp).

## Attributes

| Name | What it does | Default |
|---|---|---|
| `autoplay` | Play by itself once loaded and seen (a third of it on screen): one below the fold plays when scrolled to | `true` |
| `fit` | Animation fit mode (BoxFit) (contain, cover, fill, fitWidth, fitHeight, none) | `contain` |
| `height` | Animation height in pixels | `200` |
| `id` | Media command registry ID (#id.play, #id.reset, #id.stop) |  |
| `offscreen` | wait: autoplay starts once a third of it is on screen. play: at once, seen or not (an animation tied to a moment). (wait, play) | `wait` |
| `repeat` | Loop playback | `false` |
| `src` | The .json Lottie file: https://, a server or asset path, file:/ (the app's own file when it runs from its files) or a path on the device, as <img src>. None, or one that can't be loaded: its space stays empty and a debug warning says why. |  |
| `width` | Animation width in pixels | `200` |

## Commands

| Name | What it does |
|---|---|
| `play` | Play the animation. |
| `reset` | Back to the first frame. |
| `stop` | Stop it. |

Any tag also takes gestures: `@on.tap`, `@on.longpress`, `@on.doubletap` and `@on.swipeleft` (and right, up and down). `@click` runs on a tap too.

## Related tags

- [`<column>`](https://hypeapps.dev/docs/reference/column.md): Stacks its children top to bottom, with a gap between them and an alignment across.
- [`<text>`](https://hypeapps.dev/docs/reference/text.md): A run of text; with @text it shows an expression that updates as its variables change.
- [`<audio>`](https://hypeapps.dev/docs/reference/audio.md): A compact audio player bar with play, a progress track and the track's title and artist.
- [`<camera>`](https://hypeapps.dev/docs/reference/camera.md): A live camera viewfinder with a shutter; the photo's path goes into a variable.
- [`<canvas>`](https://hypeapps.dev/docs/reference/canvas.md): A drawing surface for finger or stylus, with a pen, eraser and color toolbar; it saves as a PNG.
- [`<file-picker>`](https://hypeapps.dev/docs/reference/file-picker.md): Opens the device's photo, video or file picker (or the camera) and puts the chosen file in a variable.
- [`<img>`](https://hypeapps.dev/docs/reference/img.md): Shows a picture from a URL or the app's files, sized and cropped by its style.
- [`<layer>`](https://hypeapps.dev/docs/reference/layer.md): Declares one layer of a drawing surface: a locked picture to trace over, and a layer to paint on.

All tags: https://hypeapps.dev/docs/reference.md · The full reference: https://hypeapps.dev/llms.txt
