@alfonmga/react-lottie-light-ts

中文文档
0.0.1发布于 2020/01/16MITTypeScriptESM + CJS近 30 天下载 2082

React/Typescript wrapper for awesome Airbnb's lottie-web lib.

原始使用文档
文档目录8 节
  1. Demo
  2. Installation
  3. Usage
  4. Params
  5. Props
  6. Config
  7. More
  8. License

@crello/react-lottie

React/Typescript wrapper for awesome Airbnb's lottie-web lib.

Demo

https://crello.github.io/react-lottie/

you can find demo files in ./examples folder -- launch with yarn start

Installation

yarn add @crello/react-lottie or npm install --save @crello/react-lottie

Usage

Most basic react-lottie example:

import React from 'react';
import { Lottie } from '@crello/react-lottie'
import animationData from './myAwesomeAnimation.json'

export const BasicLottieComponent = () => <Lottie config={{animationData: animationData}}>

Lottie component creates <div> and passes it to lottie config as the container param. This div contains renderer's output of choosen type: 'svg'| 'html' | 'canvas'. <Lottie> accepts style and className props that will apply to the container.

Any browser events should be added on elements wrapping actual <Lottie> e.g.:

<div onClick={..}>
    <Lottie/>
<div>

Params

Props

{
  height?: string - valid css value e.g. '100px' [default: `100%`],
  width?: string - valid css value e.g. '100px' [default: `100%`],
  playingState?: 'playing' | 'stopped' | 'paused' [default: `playing`],
  segments?: AnimationSegment | AnimationSegment[],
  speed?: number - animation playback speed [default: `1`],
  style?: styles passed to lottie container,
  direction?: AnimationDirection - [default: `1`],
  lottieEventListeners?: ReactLottieEvent[] - see available events in AnimationEventName from 'lottie-web',
  config: ReactLottieConfig - config with mandatory `path` or `animationData`,
}

Config

{
  animationData: any - an Object with the exported animation data,
  path: string - remote data,
  renderer?: 'svg' | 'canvas' | 'html' - choose renderer [default: `svg`],
  loop?: boolean | number - loop boolean or count [default: `false`],
  autoplay?: boolean - it will start playing as soon as it is ready [default: `true`],
  name?: string - animation name for future reference,
  rendererSettings?: SVGRendererConfig | CanvasRendererConfig | HTMLRendererConfig,
}

More

See more details in @crello/react-lottie exports: Lottie, ReactLottieConfig, ReactLottieOwnProps, ReactLottiePlayingState

Also check out the types provided by lottie-web itself: AnimationDirection, AnimationSegment, AnimationEventName, AnimationEventCallback, AnimationItem, BaseRendererConfig, SVGRendererConfig, CanvasRendererConfig, HTMLRendererConfig, AnimationConfig, AnimationConfigWithPath, AnimationConfigWithData, Lottie

More lottie animations you can find on lottiefiles

License

MIT

版本与发布记录

@alfonmga/react-lottie-light-ts 共发布 1 个版本,首次发布于 2020/01/16;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.0.1latest2020/01/166 年前

关于 @alfonmga/react-lottie-light-ts 的常见问题

@alfonmga/react-lottie-light-ts 是什么?

React/Typescript wrapper for awesome Airbnb's lottie-web lib.

如何安装 @alfonmga/react-lottie-light-ts?

在项目目录运行 npm install @alfonmga/react-lottie-light-ts,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(~16.9.0)、react-dom(~16.9.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@alfonmga/react-lottie-light-ts 支持 TypeScript 吗?

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

@alfonmga/react-lottie-light-ts 支持 ESM 还是 CommonJS?

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

@alfonmga/react-lottie-light-ts 可以商用吗?

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

@alfonmga/react-lottie-light-ts 的下载量有多少?

根据 npm 官方下载统计,@alfonmga/react-lottie-light-ts 在 2026/10/06 – 2026/11/04 这 30 天内被下载 2,082 次,日均约 69 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@alfonmga/react-lottie-light-ts 还在维护吗?

最新版本 0.0.1 发布于 2020/01/16(6 年前);至今共发布 1 个版本,其中过去 12 个月发布了 0 个;首次发布于 2020/01/16。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。