# @lottiefiles/dotlottie-svelte > [!TIP] > Looking for animations to use with this player? Browse **[100,000+ free Lottie animations](https://lottiefiles.com/free-animations?utm_source=npm&utm_medium=readme)** and grab any of them as `.lottie` or `.json`, or create your own with [Lottie Creator](https://lottiefiles.com/lottie-creator?utm_source=npm&utm_medium=readme). ![npm](https://img.shields.io/npm/v/@lottiefiles/dotlottie-svelte) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/%40lottiefiles%2Fdotlottie-svelte) ![npm](https://img.shields.io/npm/dt/%40lottiefiles/dotlottie-svelte) ![NPM](https://img.shields.io/npm/l/@lottiefiles/dotlottie-svelte)

dotLottie Web

## Contents * [Introduction](#introduction) * [What is dotLottie?](#what-is-dotlottie) * [Installation](#installation) * [Usage](#usage) * [Live Examples](#live-examples) * [APIs](#apis) * [Props](#props) * [Custom Playback Controls](#custom-playback-controls) * [Listening to Events](#listening-to-events) * [Development](#development) * [Setup](#setup) * [Dev](#dev) * [Build](#build) ## Introduction A Svelte component for rendering [Lottie](https://lottiefiles.github.io/lottie-docs/) and [dotLottie](https://lottiefiles.com/dotlottie) animations. It acts as a wrapper around the [`dotLottie`](../web/README.md) web player. ### What is dotLottie? dotLottie is an open-source file format that aggregates one or more Lottie files and their associated resources into a single file. They are ZIP archives compressed with the Deflate compression method and carry the file extension of ".lottie". [Learn more about dotLottie](https://lottiefiles.com/dotlottie). ## Installation ```bash npm install @lottiefiles/dotlottie-svelte ``` ## Usage ```svelte ``` ## Live Examples ## APIs ### Props | Property name | Type | Required | Default | Description | | | ----------------------- | ---------------------------------------------------------------- | :------: | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - | | `autoplay` | boolean | | false | Auto-starts the animation on load. | | | `loop` | boolean | | false | Determines if the animation should loop. | | | `src` | string | | undefined | URL to the animation data (`.json` or `.lottie`). | | | `speed` | number | | 1 | Animation playback speed. 1 is regular speed. | | | `data` | string \| ArrayBuffer | | undefined | Animation data provided either as a Lottie JSON string or as an ArrayBuffer for .lottie animations. | | | `mode` | string | | "forward" | Animation play mode. Accepts "forward", "reverse", "bounce", "reverse-bounce". | | | `backgroundColor` | string | | undefined | Background color of the canvas. Accepts 6-digit or 8-digit hex color string (e.g., "#000000", "#000000FF"), | | | `segment` | \[number, number] | | undefined | Animation segment. Accepts an array of two numbers, where the first number is the start frame and the second number is the end frame. | | | `renderConfig` | RenderConfig | | undefined | Configuration for rendering the animation. | | | `dotLottieRefCallback` | (dotLottie: [DotLottie](../web/README.md#documentation)) => void | | undefined | Callback function that receives a reference to the [`dotLottie`](../web/README.md) web player instance once instantiated. | | | `useFrameInterpolation` | boolean | | true | Determines if the animation should update on subframes. If set to false, the original AE frame rate will be maintained. If set to true, it will refresh at each requestAnimationFrame, including intermediate values. The default setting is true. | | | `autoResizeCanvas` | boolean | | true | Determines if the canvas should resize automatically to its container | | #### RenderConfig The `renderConfig` object accepts the following properties: | Property name | Type | Required | Default | Description | | ------------------ | ------ | :------: | ----------------------------- | ----------------------- | | `devicePixelRatio` | number | | window\.devicePixelRatio \| 1 | The device pixel ratio. | ## Custom Playback Controls `DotLottieSvelte` component makes it easy to build custom playback controls for the animation. It exposes a `dotLottieRefCallback` prop that can be used to get a reference to the [`dotLottie`](../web/README.md#documentation) web player instance. This instance can be used to control the playback of the animation using the methods exposed by the [`dotLottie`](../web/README.md#documentation) web player instance. Here is an example: ```svelte dotLottie = ref} /> ``` You can find the list of methods that can be used to control the playback of the animation [here](../web/README.md#documentation). ## Listening to Events `DotLottieSvelte` component can receive a `dotLottieRefCallback` prop that can be used to get a reference to the [`dotLottie`](../web/README.md#documentation) web player instance. This reference can be used to listen to player events emitted by the [`dotLottie`](../web/README.md#documentation) web instance. Here is an example: ```svelte { dotLottie = ref; setupListeners(dotLottie); }} /> ``` [dotLottie](../web/README.md#documentation) instance exposes multiple events that can be listened to. You can find the list of events [here](../web/README.md#documentation). ## Development ### Setup ```bash pnpm install ``` ### Dev ```bash pnpm dev ``` ### Build ```bash pnpm build ```