1. Reference
  2. Media

<animation>

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

Media

This tag has more than one name. Every spelling is the same tag, so write whichever feels natural. Pick one and every example on this page uses it.

animation.ham
<column style="gap-8 items-center w-full">
    <animation id="logo"
               src="https://hypeapps.dev/gallery/assets/loader.json"
               width="160"
               height="160"
               repeat="true"/>
    <text style="muted">Loading your apps…</text>
</column>
The snippet drawn by Hype Apps on a phone, in light mode The snippet drawn by Hype Apps on a phone, in dark mode
This snippet as Hype Apps draws it on a phone. It follows this page's light or dark theme.

Attributes

NameWhat it doesDefault
autoplay Play by itself once loaded and seen (a third of it on screen): one below the fold plays when scrolled to
boolean
true
fit Animation fit mode (BoxFit)
contain, cover, fill, fitWidth, fitHeight, none
contain
height Animation height in pixels
number
200
id Media command registry ID (#id.play, #id.reset, #id.stop)
string
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
boolean
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.
string
width Animation width in pixels
number
200

Commands

NameWhat 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.

This page is also Markdown, and all of HAM is in llms.txt.