www.npmjs.com Open in urlscan Pro
2606:4700::6811:b0ab  Public Scan

URL: https://www.npmjs.com/package/@lottiefiles/lottie-player/v/2.0.7?activeTab=code
Submission: On October 30 via manual from AU — Scanned from AU

Form analysis 1 forms found in the DOM

GET /search

<form id="search" method="GET" action="/search" class="_13c93d41 relative flex bg-transparent ph3 ph2 pv2 ph0-ns pv0-ns bt b--black-10 bn-ns">
  <div class="e82b10fd relative dde91b96">
    <div class="_2f299eeb nowrap flex"><span class="_705cdf4f db fl pl3 pr1"><svg width="15px" height="15px" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" aria-hidden="true">
          <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
            <g stroke="#777777" stroke-width="1.3">
              <g>
                <path d="M13.4044,7.0274 C13.4044,10.5494 10.5494,13.4044 7.0274,13.4044 C3.5054,13.4044 0.6504,10.5494 0.6504,7.0274 C0.6504,3.5054 3.5054,0.6504 7.0274,0.6504 C10.5494,0.6504 13.4044,3.5054 13.4044,7.0274 Z"></path>
                <path d="M11.4913,11.4913 L17.8683,17.8683"></path>
              </g>
            </g>
          </g>
        </svg></span><input type="search" role="combobox" name="q" hotkeys="[object Object]" placeholder="Search packages" aria-label="Search packages" aria-controls="typeahead-list-1230467" aria-expanded="false" aria-activedescendant=""
        inputref="[object Object]" autocomplete="off" class="_390acbc5 f5 fw3 black relative" value="" element="input"></div>
  </div><button type="submit" class="_0da775bb bn pv2 ph4 f6 white pointer bn pv2 ph4 f6 white pointer" aria-label="Search">Search</button><input type="hidden" name="csrftoken" value="9axvqmOQfeufxZHkFsR3AFDInmAxBHrbIQIfrC7pzi6">
</form>

Text Content

skip to:contentpackage searchsign in
❤
 * Pro
 * Teams
 * Pricing
 * Documentation

npm


Search
Sign UpSign In


@LOTTIEFILES/LOTTIE-PLAYER


2.0.7 • Public • Published 18 minutes ago
 * Readme
 * Code Beta
 * 5 Dependencies
 * 73 Dependents
 * 57 Versions


LOTTIE-PLAYER WEB COMPONENT

This is a Web Component for easily embedding and playing Lottie animations and
the Lottie-based Telegram Sticker (tgs) animations in websites.




DEMO



Basic usage examples


DOCUMENTATION

For full documentation, visit docs.lottiefiles.com/lottie-player


INSTALLATION

IN HTML, IMPORT FROM CDN OR FROM THE LOCAL INSTALLATION:

LOTTIE PLAYER:

 * Import from CDN.

<script src="https://unpkg.com/@lottiefiles/lottie-player@latest/dist/lottie-player.js"></script>

 * Import from local node_modules directory.

<script src="/node_modules/@lottiefiles/lottie-player/dist/lottie-player.js"></script>

TELEGRAM STICKER (TGS) PLAYER:

 * Import from CDN.

<script src="https://unpkg.com/@lottiefiles/lottie-player@latest/dist/tgs-player.js"></script>

 * Import from local node_modules directory.

<script src="/node_modules/@lottiefiles/lottie-player/dist/tgs-player.js"></script>

IN JAVASCRIPT OR TYPESCRIPT:

 1. Install package using npm or yarn.

npm install --save @lottiefiles/lottie-player

 2. Import package in your code.

import "@lottiefiles/lottie-player";


USAGE


LOTTIE-PLAYER

Add the element lottie-player and set the src property to a URL pointing to a
valid Bodymovin JSON.

<lottie-player
  autoplay
  controls
  loop
  mode="normal"
  src="https://assets3.lottiefiles.com/packages/lf20_UJNc2t.json"
  style="width: 320px"
>
</lottie-player>

You may set and load animations programatically as well.

<lottie-player autoplay controls loop mode="normal" style="width: 320px">
</lottie-player>

const player = document.querySelector("lottie-player");
player.addEventListener("rendered", (e) => {
  //Load via URL
  player.load("https://assets3.lottiefiles.com/packages/lf20_UJNc2t.json");
  // or load via a Bodymovin JSON string/object
  player.load(
    '{"v":"5.3.4","fr":30,"ip":0,"op":38,"w":315,"h":600,"nm":"new", ... }'
  );
});


TGS-PLAYER

Add the element tgs-player and set the src property to a URL pointing to a valid
TGS JSON.

<tgs-player autoplay loop mode="normal" src="https//domain/example.tgs">
</tgs-player>


REACTJS & VUEJS

Import the player either as

import * as LottiePlayer from "@lottiefiles/lottie-player";

or

require("@lottiefiles/lottie-player");

Use as follows

<lottie-player
  autoplay
  controls
  loop
  mode="normal"
  src="https://assets3.lottiefiles.com/packages/lf20_UJNc2t.json"
  style="width: 320px"
></lottie-player>


TYPESCRIPT REACTJS

Import the player either as

import * as LottiePlayer from "@lottiefiles/lottie-player";

or

require("@lottiefiles/lottie-player");

Use as follows

<lottie-player
  autoplay
  controls
  loop
  mode="normal"
  src="https://assets3.lottiefiles.com/packages/lf20_UJNc2t.json"
  style="width: 320px"
></lottie-player>

For typescript projects an added step is required. The component must be
declared as a JSX intrinsic element. Create a file 'declarations.d.ts' in the
root of your project and add the code below to the file.

declare namespace JSX {
  interface IntrinsicElements {
    "lottie-player": any;
  }
}


NUXT 2

Create a lottie-player.js file inside the /plugins folder and add the below code
to the file:

import * as LottiePlayer from "@lottiefiles/lottie-player";


Open nuxt.config.js file and add the following entry to register the newly
created plugin:

export default {
  plugins: [{ src: "~/plugins/lottie-player.js", mode: "client" }]
}

This is because the player script needs to be rendered on the browser/client
side and we must configure Nuxt to load the script on the client side only.

You would then be able to use the player as follows inside any component:

<lottie-player
  autoplay
  controls
  loop
  style="width:400px"
  src="https://assets3.lottiefiles.com/packages/lf20_RItkEz.json"
  speed="1"
  debug
/>


NUXT 3

The process for Nuxt 3 is slightly different.
Create a lottie-player.client.ts file inside the /plugins folder and add the
below code to the file:

import * as LottiePlayer from "@lottiefiles/lottie-player";

export default LottiePlayer;


Your plugin will be automatically available throughout your Nuxt application
thanks to the plugin auto-registration. Note the client suffix in the name of
the plugin - this tells Nuxt to load it only on the client side, as the Lottie
Player script can only be rendered in the browser.

You would then be able to use the player as follows inside any component:

<lottie-player
  autoplay
  controls
  loop
  style="width:400px"
  src="https://assets3.lottiefiles.com/packages/lf20_RItkEz.json"
  speed="1"
  debug
/>


NEXTJS

The process to import in NextJS is similar to Nuxt in the sense that on SSR
mode, the library must be declared as a client side module. To do this, import
the library within a react useEffect hook.

import React, { useRef } from "react";

export default function Home() {
  const ref = useRef(null);
  React.useEffect(() => {
    import("@lottiefiles/lottie-player");
  });
  return (
    <div className={styles.container}>
      <main className={styles.main}>
        <lottie-player
          id="firstLottie"
          ref={ref}
          autoplay
          controls
          loop
          mode="normal"
          src="https://assets4.lottiefiles.com/packages/lf20_gb5bmwlm.json"
          style={{ width: "300px", height: "300px" }}
        ></lottie-player>
      </main>
    </div>
  );
}

Do add a declaration file named declaration.d.ts to the root of the project as
well

declare namespace JSX {
  interface IntrinsicElements {
    "lottie-player": any;
  }
}

Full documentation on player properties, methods, events and styling for the
Lottie-player are available here.


COMMUNITY & SUPPORT

 * Github issues. For bugs and errors you encounter using this player.
 * Discord. For hanging out with the community and sharing your awesome Lottie
   animations!


OUR OTHER LOTTIE RELATED LIBRARIES

Project Description lottie-react A React component for the Lottie Web player.
lottie-vue A Vue component for the Lottie player. svelte-lottie-player Lottie
player component for use with Svelte. jLottie jLottie is suitable as a general
purpose lottie player, though implements a subset of the features in the core
player - this approach leads to a tiny footprint and great performance.
lottie-interactivity This is a small library to add scrolling, cursor
interactivity and interaction chaining to your Lottie Animations. 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". lottie-js The library consists of methods to map the Lottie JSON to
the object model and interact with properties as well as manipulate them.
lottie-theming A library to extract themable properties and apply different
themes to a given Lottie


LICENSE

MIT License © LottieFiles.com


/@LOTTIEFILES/LOTTIE-PLAYER/

/@lottiefiles/lottie-player/
 * 
   dist/
   folder
   9.74 MB
 * 
   LICENSE
   text/plain
   1.07 kB
 * 
   README.md
   text/markdown
   9.41 kB
 * 
   package.json
   application/json
   2.74 kB








PACKAGE SIDEBAR


INSTALL

npm i @lottiefiles/lottie-player


REPOSITORY

Gitgithub.com/LottieFiles/lottie-player


HOMEPAGE

lottiefiles.com/web-player


DOWNLOADSWEEKLY DOWNLOADS

88,991


VERSION

2.0.7


LICENSE

MIT


UNPACKED SIZE

9.75 MB


TOTAL FILES

21


ISSUES

56


PULL REQUESTS

18


LAST PUBLISH

18 minutes ago


COLLABORATORS

 * 
 * 
 * 

Try on RunKit
Report malware


FOOTER


SUPPORT

 * Help
 * Advisories
 * Status
 * Contact npm


COMPANY

 * About
 * Blog
 * Press


TERMS & POLICIES

 * Policies
 * Terms of Use
 * Code of Conduct
 * Privacy