Note this project is a fork of https://github.com/Gamote/lottie-react and uses lottie-web light (which does not support action script animations). Additionally prop-types have been removed and some cleanup is done in regards of the typings. Functionality is exactly the same.
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.
-
Make sure you have the peer-dependencies installed:
react
andreact-dom
.Note: This library is using React Hooks so the minimum version required for both react and react-dom is v16.8.0.
Install lottie-react using npm:
npm i @novemberfiveco/lottie-react-light
Using the component (try it)
import Lottie from "@novemberfiveco/lottie-react-light";
import groovyWalkAnimation from "./groovyWalk.json";
const App = () => <Lottie animationData={groovyWalkAnimation} loop={true} />;
export default App;
import { useLottie } from "@novemberfiveco/lottie-react-light";
import groovyWalkAnimation from "./groovyWalk.json";
const App = () => {
const options = {
animationData: groovyWalkAnimation,
loop: true
};
const { View } = useLottie(options);
return <>{View}</>;
};
export default App;
Run the tests using the yarn test
command.
-----------------------------|---------|----------|---------|---------|-------------------
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 |
-----------------------------|---------|----------|---------|---------|-------------------
Any questions or suggestions? Use the Discussions tab. Any issues? Don't hesitate to document it in the Issues tab, and we will do our best to investigate it and fix it. Any solutions? You are very welcomed to open a pull request.
👩💻
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 under thev3
branch. And of course, you are encouraged to contribute. :)
Thank you for investing your time in contributing to our project! ✨
- lottie-web - Lottie implementation for Web. Our project is based on it, and you might want to check it out in order to have a better understanding on what's behind this package or what features could 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 files? LottieFiles has a lot of them!
lottie-react is available under the MIT license.
Thanks to David Probst Jr for the animations used in the examples.