@dotlottie/player-component

中文文档
2.7.12发布于 2024/03/21MITTypeScriptESM + CJS近 30 天下载 14.3万

dotLottie animation player web component.

此软件包已被标记为弃用

This package is superceded by @lottiefiles/dotlottie-wc

原始使用文档
文档目录10 节
  1. What's dotLottie?
  2. Documentation
  3. Installation
  4. Usage
  5. Usage example in ReactJS
  6. Usage example in ReactJS + Typescript
  7. Usage example in NuxtJS / VueJS
  8. Community & Support
  9. Our other Lottie related libraries
  10. License

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/[email protected]/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!
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.
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

版本与发布记录

@dotlottie/player-component 共发布 53 个版本,首次发布于 2020/01/24;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.7.12latest2024/03/212 年前
2.7.112024/03/052 年前
2.7.102024/02/162 年前
2.7.92024/02/132 年前
2.7.82024/01/192 年前
2.7.72024/01/192 年前

其他发布通道:beta → 2.0.0-beta.6。

关于 @dotlottie/player-component 的常见问题

@dotlottie/player-component 是什么?

dotLottie animation player web component.注意:该包已被作者标记为弃用——This package is superceded by @lottiefiles/dotlottie-wc

如何安装 @dotlottie/player-component?

在项目目录运行 npm install @dotlottie/player-component,或使用 pnpm add / yarn add / bun add。

@dotlottie/player-component 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@dotlottie/player-component 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@dotlottie/player-component 可以商用吗?

@dotlottie/player-component 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@dotlottie/player-component 的下载量有多少?

根据 npm 官方下载统计,@dotlottie/player-component 在 2026/10/13 – 2026/11/11 这 30 天内被下载 143,100 次,日均约 4,770 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dotlottie/player-component 还在维护吗?

最新版本 2.7.12 发布于 2024/03/21(2 年前);至今共发布 53 个版本,其中过去 12 个月发布了 0 个;首次发布于 2020/01/24。作者已将其标记为弃用,新项目建议寻找替代方案。