MCPcopy Index your code
hub / github.com/LottieFiles/dotlottie-web

github.com/LottieFiles/dotlottie-web @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
1,071 symbols 2,394 edges 149 files 478 documented · 45% 2 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

npm npm bundle size npm downloads jsDelivr hits GitHub

dotLottie Web

dotLottie Web

The official LottieFiles player for Lottie (.json) and dotLottie (.lottie) animations on the web — a Rust + WASM core powered by ThorVG, with Software, WebGL2, and WebGPU rendering backends and full dotLottie v2 support (theming, state machines, and audio).

🌐 Live Viewer · 📊 Perf Playground · 📚 Docs · 🦀 dotLottie-rs

Why dotLottie Web

  • 📦 Lottie + dotLottie, one player — point src at a classic Lottie .json or a .lottie archive. The .lottie format bundles multiple animations, themes, state machines, and embedded assets into a single compressed file.
  • 🦀 Rust + WASM core — powered by dotlottie-rs, the same engine that ships in iOS, Android, and native dotLottie players. One battle-tested implementation across every platform.
  • 🎨 ThorVG renderer — an industrial-grade vector graphics engine with the broadest Lottie feature coverage of any web renderer. See the ThorVG Lottie support matrix.
  • Three rendering backends — Software (Canvas2D), WebGL2, and WebGPU (experimental). Switch with a one-line import change — same DotLottie class everywhere.
  • 📁 dotLottie v2 ready — first-class theming, interactive state machines, and audio in a single .lottie file. No userland wiring required.
  • 🧵 Off-main-threadDotLottieWorker renders on a Web Worker with OffscreenCanvas, keeping your UI buttery-smooth even with dozens of animations.
  • ⚛️ 6 first-party SDKs — Vanilla JS, React, Vue, Svelte, Solid, and a Web Component. Plus SSR-safe (Next.js example included) and Node.js 18+ support.
  • 🎛️ Rich runtime control — themes, slots (color/scalar/vector/gradient/text/image), markers, segments, layouts (fit + align), playback modes (forward/reverse/bounce), frame interpolation, 25+ typed events.

Quick Start

Install the package for your framework, then drop in a few lines. The same player loads both Lottie .json and dotLottie .lottie files — just point src at either:

Vanilla JS

npm install @lottiefiles/dotlottie-web
<canvas id="canvas" style="width: 300px; height: 300px"></canvas>
import { DotLottie } from '@lottiefiles/dotlottie-web';

const dotLottie = new DotLottie({
  canvas: document.getElementById('canvas'),
  src: 'https://your-animation-url.lottie',
  autoplay: true,
  loop: true,
});

⚛️ React

bash npm install @lottiefiles/dotlottie-react

```jsx import { DotLottieReact } from '@lottiefiles/dotlottie-react';

const App = () => ( ); ```

💚 Vue

bash npm install @lottiefiles/dotlottie-vue

```vue

```

🧡 Svelte

bash npm install @lottiefiles/dotlottie-svelte

```svelte

```

🔵 Solid

bash npm install @lottiefiles/dotlottie-solid

```jsx import { DotLottieSolid } from '@lottiefiles/dotlottie-solid';

const App = () => ( ); ```

🌐 Web Component (drop-in, no build step)

```html <dotlottie-wc src="https://lottie.host/4db68bbd-31f6-4cd8-84eb-189de081159a/IGmMCqhzpt.lottie" autoplay loop

```

Or via npm:

bash npm install @lottiefiles/dotlottie-wc

js import '@lottiefiles/dotlottie-wc';

Features

🤖 Interactive State Machines

dotLottie v2 ships state machines built into the file format — no JS glue required. Define states, transitions, and inputs in a single .lottie and drive them at runtime through pointer events, custom events, or input values.

const dotLottie = new DotLottie({
  canvas: document.getElementById('canvas'),
  src: 'interactive-button.lottie',
  stateMachineId: 'main',
  autoplay: true,
});

The player exposes typed events for stateMachineStart, stateMachineTransition, stateMachineStateEntered, custom events, and input changes — perfect for wiring animations into your UI logic.

🎨 Runtime Theming

Switch palettes, animate gradients, swap text, or replace images at runtime — without re-exporting from After Effects. Themes can be embedded in the .lottie manifest or supplied programmatically.

// Use a theme defined in the .lottie manifest
dotLottie.setTheme('dark');

// Or supply a theme object at runtime
dotLottie.setThemeData({
  rules: [
    { id: 'primary', type: 'Color', value: [0.9, 0.2, 0.4, 1.0] },
  ],
});

The full Theme type covers color, scalar, position, vector, gradient, image, and text rules — all keyframe-aware.

🔊 Audio Support

dotLottie files can carry embedded audio tracks alongside the animation timeline — handy for UI sound effects, onboarding flows, or interactive characters. Audio is decoded and played in lockstep with the animation timeline.

Audio is an experimental feature in dotlottie-rs. Browser autoplay policies still apply — initiate playback from a user gesture.

🧵 Off-Main-Thread Rendering

For pages with many animations, swap DotLottie for DotLottieWorker. Identical API, but rendering happens on a Web Worker with an OffscreenCanvas, freeing the main thread for layout, scrolling, and your app code.

import { DotLottieWorker } from '@lottiefiles/dotlottie-web';

const player = new DotLottieWorker({
  canvas: document.getElementById('canvas'),
  src: 'animation.lottie',
  autoplay: true,
  loop: true,
  workerId: 'shared-pool', // optional: share one worker across many instances
});

All DotLottieWorker methods are async (Promise-returning) since they cross a worker boundary.

⚡ Hardware-Accelerated Rendering

The default Software backend works everywhere. For demanding workloads — many concurrent animations, large canvases, complex masks — opt in to GPU rendering via subpath imports:

// WebGL2 — broadly supported
import { DotLottie } from '@lottiefiles/dotlottie-web/webgl';

// WebGPU — experimental, modern Chromium / Safari TP
import { DotLottie } from '@lottiefiles/dotlottie-web/webgpu';

The class name (DotLottie) and API surface are identical across all three backends, so swapping renderers is a one-line change. Each backend ships its own optimized WASM build via package.json conditional exports.

Want to see the difference on your own hardware? The hosted perf-test page compares Software vs WebGL vs WebGPU vs Skottie/CanvasKit head-to-head.

🖼️ More built-in capabilities

  • Multi-animation .lottie filesanimationId config + loadAnimation(id) to switch between bundled animations
  • Named markerssetMarker(name) and markers() to play AE-defined segments
  • Frame segmentssetSegment(start, end) for arbitrary frame ranges
  • Layoutfit (contain / cover / fill / fit-width / fit-height / none) + normalized align: [x, y]
  • Slots — bind dynamic data to color, scalar, vector, gradient, text, and image slots at runtime
  • Playback modesforward / reverse / bounce / reverse-bounce with configurable loop counts
  • Frame interpolation — smooth subframe playback (default on) or pinned to the original AE frame rate
  • Freeze on offscreen — automatically pause rendering when the canvas leaves the viewport
  • 25+ typed eventsplay, pause, frame, complete, loop, load, loadError, freeze, plus the full state-machine event suite

Packages

All packages render both Lottie (.json) and dotLottie (.lottie) animations.

Package Description
@lottiefiles/dotlottie-web Core Lottie & dotLottie player — Rust/WASM via dotlottie-rs, Canvas2D / WebGL / WebGPU, Node-isomorphic
@lottiefiles/dotlottie-react React component for Lottie & dotLottie
@lottiefiles/dotlottie-vue Vue 3 component for Lottie & dotLottie
@lottiefiles/dotlottie-svelte Svelte component for Lottie & dotLottie
@lottiefiles/dotlottie-solid Solid component for Lottie & dotLottie
@lottiefiles/dotlottie-wc Framework-agnostic Web Component for Lottie & dotLottie

Each package README contains its full API reference, prop tables, and event documentation.

dotLottie Viewer

A hosted companion app at lottiefiles.github.io/dotlottie-web for inspecting, debugging, and benchmarking animations:

Page What it does
Home Drop a .lottie or .json file to preview rendering and inspect manifest details
Playground Interactive editor for player config, themes, markers, and animation switching
Performance Stress test across 40+ animations — compare Software / WebGL / WebGPU / Skottie head-to-head on your own hardware, with seedable runs for reproducibility
List Gallery of curated animations
Embed Embedding patterns and demos

Source: apps/viewer/.

Live Examples (CodePen)

@lottiefiles/dotlottie-webGetting Started · Playback Controls · Dynamic Loading · Worker · Multi Animations · Advanced Layout · Named Markers · Theming · Interactivity

@lottiefiles/dotlottie-reactGetting Started · Custom Controls

*

Extension points exported contracts — how you extend this code

AnimationFrameStrategy (Interface)
(no doc) [5 implementers]
packages/web/src/animation-frame-manager.ts
DotLottieComponentProps (Interface)
(no doc)
packages/solid/src/use-dotlottie.tsx
DotLottieVueProps (Interface)
(no doc)
packages/vue/src/dotlottie.ts
DotLottieCDNPlayerProps (Interface)
(no doc)
apps/viewer/src/components/dotlottie-cdn-player.tsx
Args (Interface)
(no doc)
examples/web-node/index.ts
BaseEvent (Interface)
(no doc)
packages/web/src/event-manager.ts
UseDotLottieReturn (Interface)
(no doc)
packages/solid/src/use-dotlottie.tsx
DotLottieVueExposed (Interface)
(no doc)
packages/vue/src/dotlottie.ts

Core symbols most depended-on inside this repo

addEventListener
called by 340
packages/web/src/dotlottie.ts
dispatch
called by 86
packages/web/src/event-manager.ts
_sendMessage
called by 76
packages/web/src/worker/dotlottie.ts
_updateDotLottieInstanceState
called by 48
packages/web/src/worker/dotlottie.ts
removeEventListener
called by 41
packages/web/src/dotlottie.ts
passStringToWasm0
called by 41
packages/web/src/webgl/dotlottie-player.js
passStringToWasm0
called by 39
packages/web/src/webgpu/dotlottie-player.js
passStringToWasm0
called by 38
packages/web/src/core/dotlottie-player.js

Shape

Method 646
Function 275
Interface 106
Class 41
Enum 3

Languages

TypeScript100%

Modules by API surface

packages/web/src/webgl/dotlottie-player.js144 symbols
packages/web/src/webgpu/dotlottie-player.js142 symbols
packages/web/src/core/dotlottie-player.js139 symbols
packages/web/src/dotlottie.ts131 symbols
packages/web/src/worker/dotlottie.ts114 symbols
packages/web/src/event-manager.ts33 symbols
packages/web/src/types.ts31 symbols
packages/web/src/worker/dotlottie.worker.ts21 symbols
apps/viewer/src/components/slot-controller.tsx18 symbols
packages/web/src/animation-frame-manager.ts16 symbols
packages/web/src/webgpu/dotlottie-webgpu.ts14 symbols
examples/solid/src/App.tsx14 symbols

Used by 2 indexed graphs manifest dependencies, hub-wide

For agents

$ claude mcp add dotlottie-web \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact