Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dotlottie/player-component

Package Overview
Dependencies
Maintainers
3
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dotlottie/player-component

dotLottie animation player web component.

  • 2.7.12
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
63K
increased by6.14%
Maintainers
3
Weekly downloads
 
Created
Source

dotlottie-player Web Component

npm webcomponents.org

This is a Web Component for easily embedding and playing dotLottie animations on websites.

What's 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".

Read more about .lottie here!

Documentation

View the full documentation

Installation

In HTML, import from CDN or from the local Installation
Lottie Player
  • Import from CDN.
<script type="module" src="https://unpkg.com/@dotlottie/player-component@2.3.0/dist/dotlottie-player.mjs" ></script>
  • Import from local node_modules directory.
<script type="module" src="/node_modules/@dotlottie/player-component/dist/dotlottie-player.mjs"></script>
In Javascript or TypeScript
  1. Install package using npm or yarn.
npm install --save @dotlottie/player-component
  1. Import package in your code.
import '@dotlottie/player-component';

Usage

Add the element dotlottie-player and set the src property to a URL pointing to a .lottie or .json file.

<dotlottie-player
  autoplay
  controls
  loop
  playMode="normal"
  src="http://dotlottieio.s3-website-us-east-1.amazonaws.com/sample_files/animation-external-image.lottie"
  style="width: 320px"
>
</dotlottie-player>

You may set and load animations programmatically as well.

<dotlottie-player autoplay controls loop mode="normal" style="width: 320px"> </dotlottie-player>
const player = document.querySelector('dotlottie-player');
player.load('http://dotlottieio.s3-website-us-east-1.amazonaws.com/sample_files/animation-external-image.lottie');

Usage example in ReactJS

1 - import the player and use as follows

import '@dotlottie/player-component';

function App() {
  return (
    <div className="App">
      <dotlottie-player
        src="https://assets2.lottiefiles.com/dotlotties/dlf10_l12sw9oo.lottie"
        autoplay
        loop
        style={{ height: '100%', width: '100%' }}
      />
    </div>
  );
}

export default App;

Usage example in ReactJS + Typescript

1 - import as follows

import '@dotlottie/player-component';

function App() {
  return (
    <div className="App">
      <dotlottie-player
        src="https://assets2.lottiefiles.com/dotlotties/dlf10_l12sw9oo.lottie"
        autoplay
        loop
        style={{ height: '100%', width: '100%' }}
      />
    </div>
  );
}

export default App;

2 - create a global.d.ts file in your src folder and add the code below

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

Usage example in NuxtJS / VueJS

1 - update the plugins array in nuxt.config.js file in your root as follows

plugins: [{ src: '~/plugins/lottie-player', mode: 'client' }];

2 - create a folder plugins in your root if it doesnt already exist, add a file lottie-player.js with the following content

import * as LottiePlayer from '@dotlottie/player-component';

3 - the component can now be used in your pages or components template tag as follows without any import necessary

<template>
  <dotlottie-player src="https://assets2.lottiefiles.com/dotlotties/dlf10_l12sw9oo.lottie" autoplay loop />
</template>
<script>
export default {};
</script>
  • note for vueJS the library/player must be declared as a client side plugin module.

Full documentation on player properties, methods, events and styling for the dotlottie-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!
ProjectDescription
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.
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.

License

MIT License © LottieFiles.com

Keywords

FAQs

Package last updated on 21 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc