react-lottie vs react-lottie-player
React Animation Libraries Comparison
1 Year
react-lottiereact-lottie-playerSimilar Packages:
What's React Animation Libraries?

Both react-lottie and react-lottie-player are libraries designed to integrate Lottie animations into React applications, allowing developers to create rich, interactive animations easily. Lottie is an open-source animation file format that's lightweight and easy to use, enabling designers to create animations in Adobe After Effects and export them as JSON files. These libraries simplify the process of rendering Lottie animations in React, enhancing user interfaces with engaging visual effects. While they serve a similar purpose, they differ in terms of features and usage patterns, making it essential to understand their distinctions to choose the right one for your project.

Package Weekly Downloads Trend
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
react-lottie298,1361,70528 kB993 months agoMIT
react-lottie-player147,609-120 kB-7 months agoMIT
Feature Comparison: react-lottie vs react-lottie-player

Animation Control

  • react-lottie:

    react-lottie provides basic control over animations, allowing you to start, stop, and loop animations. However, it lacks more advanced control features like playback speed adjustments or event listeners for animation progress.

  • react-lottie-player:

    react-lottie-player offers comprehensive control over animations, including play, pause, stop, and the ability to adjust playback speed. It also supports event listeners, enabling developers to trigger actions based on animation events.

Ease of Use

  • react-lottie:

    react-lottie is relatively easy to set up and use, making it suitable for developers who want to quickly integrate Lottie animations without much overhead. It requires minimal configuration and is straightforward for basic use cases.

  • react-lottie-player:

    react-lottie-player is also user-friendly but comes with a slightly steeper learning curve due to its additional features. Developers may need to familiarize themselves with its API to fully utilize its capabilities.

Customization

  • react-lottie:

    react-lottie allows for some customization options, but it is limited compared to react-lottie-player. Developers can adjust basic properties like animation data and loop settings, but deeper customization may require additional work.

  • react-lottie-player:

    react-lottie-player provides extensive customization options, allowing developers to manipulate various aspects of the animation, such as speed, direction, and event handling, making it a better choice for complex animations.

Performance

  • react-lottie:

    react-lottie is optimized for performance in most cases, but it may struggle with very complex animations or large JSON files, potentially leading to slower rendering times.

  • react-lottie-player:

    react-lottie-player is designed with performance in mind, providing better handling of complex animations and larger JSON files, ensuring smoother playback and less impact on application performance.

Community and Support

  • react-lottie:

    react-lottie has a solid community and support, but it may not be as actively maintained as react-lottie-player, which could affect long-term project viability.

  • react-lottie-player:

    react-lottie-player benefits from a more active development community and frequent updates, providing better support and more features over time.

How to Choose: react-lottie vs react-lottie-player
  • react-lottie:

    Choose react-lottie if you need a straightforward implementation for Lottie animations with basic controls. It is suitable for projects that require simple animation playback without extensive customization or advanced features.

  • react-lottie-player:

    Choose react-lottie-player if you require more advanced features such as playback control, event handling, and a more flexible API. It is ideal for projects that need detailed control over animation states, including play, pause, and stop functionalities.

README for react-lottie

Lottie Animation View for React (Angular, Vue)

npm version

Demo

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

Wapper of bodymovin.js

bodymovin is Adobe After Effects plugin for exporting animations as JSON, also it provide bodymovin.js for render them as svg/canvas/html.

Why Lottie?

Flexible After Effects features

We currently support solids, shape layers, masks, alpha mattes, trim paths, and dash patterns. And we’ll be adding new features on a regular basis.

Manipulate your animation any way you like

You can go forward, backward, and most importantly you can program your animation to respond to any interaction.

Small file sizes

Bundle vector animations within your app without having to worry about multiple dimensions or large file sizes. Alternatively, you can decouple animation files from your app’s code entirely by loading them from a JSON API.

Learn more › http://airbnb.design/lottie/

Looking for lottie files › https://www.lottiefiles.com/

Installation

Install through npm:

npm install --save react-lottie

Usage

Import pinjump.json as animation data

import React from 'react'
import Lottie from 'react-lottie';
import * as animationData from './pinjump.json'

export default class LottieControl extends React.Component {

  constructor(props) {
    super(props);
    this.state = {isStopped: false, isPaused: false};
  }

  render() {
    const buttonStyle = {
      display: 'block',
      margin: '10px auto'
    };

    const defaultOptions = {
      loop: true,
      autoplay: true, 
      animationData: animationData,
      rendererSettings: {
        preserveAspectRatio: 'xMidYMid slice'
      }
    };

    return <div>
      <Lottie options={defaultOptions}
              height={400}
              width={400}
              isStopped={this.state.isStopped}
              isPaused={this.state.isPaused}/>
      <button style={buttonStyle} onClick={() => this.setState({isStopped: true})}>stop</button>
      <button style={buttonStyle} onClick={() => this.setState({isStopped: false})}>play</button>
      <button style={buttonStyle} onClick={() => this.setState({isPaused: !this.state.isPaused})}>pause</button>
    </div>
  }
}

props

The <Lottie /> Component supports the following components:

options required

the object representing the animation settings that will be instantiated by bodymovin. Currently a subset of the bodymovin options are supported:

loop options [default: false]

autoplay options [default: false]

animationData required

rendererSettings required

width optional [default: 100%]

pixel value for containers width.

height optional [default: 100%]

pixel value for containers height.

eventListeners optional [default: []]

This is an array of objects containing a eventName and callback function that will be registered as eventlisteners on the animation object. refer to bodymovin#events where the mention using addEventListener, for a list of available custom events.

example:

eventListeners=[
  {
    eventName: 'complete',
    callback: () => console.log('the animation completed:'),
  },
]

isClickToPauseDisabled optional [default: false] When this props is left unspecified or is set to false animations are paused or resumed when a user clicks or taps them. If you do not want this behaviour set this prop to true.

Related Projects

Contribution

Your contributions and suggestions are heartily welcome.

License

MIT