JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1364053
  • Score
    100M100P100Q188090F
  • License MIT

Lottie for React

Package Exports

  • lottie-react
  • lottie-react/build/index.es.js
  • lottie-react/build/index.js
  • lottie-react/build/index.umd.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (lottie-react) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

lottie-react

npm version npm downloads/month Known Vulnerabilities Coverage Status Tested with jest GitHub license

This project is meant to give developers full control over Lottie instance with minimal implementation by wrapping lottie-web in a Component or Hook that can be easily used in React applications.

πŸ‘©β€πŸ’» v3 is under development and is planning to bring a lot of features and improvements. But unfortunately, at the moment all the maintainers are super busy with work related projects. You can check out the progress unde the v3 branch. And of course, you are encouraged to contribute. :)

πŸ™‹β€β™‚οΈ Are you using lottie-react in production? Please send us a message with your website, feature requests and recommendations at: contact@gamote.ro.

Installation

Install react, react-dom if you don’t have them already:

Note: This library is using React hooks so the minimum version required for both react and react-dom is 16.8.0.

yarn add react@^16.8.0 react-dom@^16.8.0

Install lottie-react using npm:

yarn add lottie-react

Usage

Component

import Lottie from "lottie-react";
import groovyWalkAnimation from "./groovyWalk.json";

const Example = () => {
  return <Lottie animationData={groovyWalkAnimation} />;
};

export default Example;

Try it on CodeSandbox

Hook

import { useLottie } from "lottie-react";
import groovyWalkAnimation from "./groovyWalk.json";

const Example = () => {
  const options = {
    animationData: groovyWalkAnimation,
    loop: true,
    autoplay: true,
  };

  const { View } = useLottie(options);

  return View;
};

export default Example;

Try it on CodeSandbox

Documentation

Checkout the Documentation for more information and examples: lottiereact.com

Test

yarn test

Coverage report

-----------------------------|---------|----------|---------|---------|-------------------
File                         | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
-----------------------------|---------|----------|---------|---------|-------------------
All files                    |     100 |      100 |     100 |     100 |                   
 components                  |     100 |      100 |     100 |     100 |                   
  Lottie.ts                  |     100 |      100 |     100 |     100 |                   
 hooks                       |     100 |      100 |     100 |     100 |                   
  useLottie.tsx              |     100 |      100 |     100 |     100 |                   
  useLottieInteractivity.tsx |     100 |      100 |     100 |     100 |                   
-----------------------------|---------|----------|---------|---------|-------------------

Contribution

Let us know if you have any suggestions or contributions. This package has the mission to help developers, so if you have any features that you think we should prioritize, reach out to us.

Projects to check out

  • lottie-web - Lottie implementation for Web. Our project is based on it and you should check it because it will help you understand what's behind this package and it will give you a better understanding on what features should you expect to have in the future.
  • lottie-android - Lottie implementation for Android
  • lottie-ios - Lottie implementation for iOS
  • lottie-react-native - Lottie implementation for React Native
  • LottieFiles - Are you looking for animations? LottieFiles is the way to go!

License

lottie-react is available under the MIT license.

Thanks to David Probst Jr for the animations used in the examples.