lottie-react-web vs react-lottie vs react-lottie-player
React Animation Libraries
lottie-react-webreact-lottiereact-lottie-playerSimilar Packages:

React Animation Libraries

These libraries facilitate the integration of Lottie animations into React applications, allowing developers to create rich, interactive animations that enhance user experience. Lottie animations are vector-based and can be scaled without losing quality, making them ideal for responsive designs. Each of these libraries offers unique features and approaches to handling Lottie animations, catering to different developer needs and preferences.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
lottie-react-web0186-436 years agoMIT
react-lottie01,73728 kB98a year agoMIT
react-lottie-player0-120 kB-2 years agoMIT

Feature Comparison: lottie-react-web vs react-lottie vs react-lottie-player

Ease of Use

  • lottie-react-web:

    lottie-react-web offers a minimalistic API that makes it easy to integrate Lottie animations into your React components without much configuration, ideal for quick implementations.

  • react-lottie:

    react-lottie provides a more comprehensive API that includes various props for controlling animation playback, making it slightly more complex but very powerful for detailed control over animations.

  • react-lottie-player:

    react-lottie-player is designed for simplicity and ease of use, allowing developers to quickly set up animations with a clean interface and straightforward props.

Animation Control

  • lottie-react-web:

    lottie-react-web provides basic support for rendering animations but lacks advanced controls for playback, making it suitable for static animations without interactive needs.

  • react-lottie:

    react-lottie excels in providing detailed control over animations, including play, pause, stop, and event callbacks, allowing for interactive and dynamic animations based on user actions.

  • react-lottie-player:

    react-lottie-player offers a balance between simplicity and control, enabling developers to easily manage playback and loop settings while still providing customization options.

Performance

  • lottie-react-web:

    lottie-react-web is lightweight and optimized for performance, making it suitable for applications where loading speed is critical and animations are used sparingly.

  • react-lottie:

    react-lottie may introduce some overhead due to its additional features, but it is still performant for most applications, especially those that require complex animations.

  • react-lottie-player:

    react-lottie-player is designed to be efficient, but its performance can vary based on the complexity of the animations and the number of instances rendered.

Customization

  • lottie-react-web:

    lottie-react-web has limited customization options, focusing primarily on rendering animations as they are, which may not suit all use cases.

  • react-lottie:

    react-lottie allows for more customization through props and event handlers, enabling developers to tailor animations to specific interactions and states.

  • react-lottie-player:

    react-lottie-player provides a user-friendly way to customize animations with props for speed, direction, and looping, making it easy to adapt animations to different contexts.

Community and Support

  • lottie-react-web:

    lottie-react-web has a smaller community compared to the other libraries, which may result in less available support and fewer resources for troubleshooting.

  • react-lottie:

    react-lottie benefits from a larger community and more extensive documentation, making it easier to find solutions and examples for common use cases.

  • react-lottie-player:

    react-lottie-player is gaining popularity and has a growing community, but it may not yet have as many resources as react-lottie.

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

  • lottie-react-web:

    Choose lottie-react-web if you need a lightweight solution that focuses on rendering Lottie animations with minimal overhead and offers a straightforward API for integrating animations into your React components.

  • react-lottie:

    Select react-lottie if you require a more feature-rich library that provides additional controls for animation playback, such as play, pause, and stop functionalities, along with event handling for animation lifecycle events.

  • react-lottie-player:

    Opt for react-lottie-player if you want a highly customizable player with a focus on ease of use, providing a simple interface for controlling animations and supporting both Lottie and SVG formats.

README for lottie-react-web

Lottie for React, React Native, iOS, and Android

npm Version License



Lottie component for React with runtime animation control.

Introduction

Lottie is a library for the Web, Android and iOS that parses Adobe After Effects animations exported as JSON with bodymovin and renders them natively on each platform!

For the first time, designers can create and ship beautiful animations without an engineer painstakingly recreating it by hand.

This library is a react-lottie fork that adds the capability for runtime animation control and fixes lots of bugs.

Getting Started

Get started with Lottie by installing the node module with yarn or npm:

yarn add lottie-react-web

or

npm i --save lottie-react-web

Usage

<Lottie> component can be used in a declarative way:

import React from 'react';
import Lottie from 'lottie-react-web'
import animation from './animation.json'

const App = () => (
  <Lottie
    options={{
      animationData: animation
    }}
  />
)

export default App

By default it will automatically play the animation in loop.

Lottie's animation control can be set via props. Here is an example of a toggle animation that reacts on click:

import React, { Component } from 'react';
import Lottie from 'lottie-react-web'
import toggleAnimation from './toggleAnimation.json'

export default class App extends Component {
  this.state = { isToggled: false }

  render() (
    <div
      onClick={() => {
        this.setState(state => { isToggled: !state.isToggled})
      }}
    >
      <Lottie
        direction={this.state.isToggled ? 1 : -1}
        options={{
          animationData: toggleAnimation,
          loop: false,
        }}
      />
    </div>
  )
)

export default App

API

These are all props available:

Props

PropDescriptionDefault
optionsMandatory - The object representing the animation settings that will be instantiated by bodymovin. Defines the source of animation (animationData), loop, autoplay, a few others. See details in the section below.{ autoplay: true, loop: true }
animationControlThis is where you can change the animation at runtime. A key value pair of a After Effects property path and the a custom value to apply to it. See details below.
widthSets the width of the animation container.100%
heightSets the heigth of the animation container.100%
isStoppedA boolean flag indicating whether or not the animation is stopped.false
isPausedA boolean flag indicating whether or not the animation is paused.false
speedAn integer indicating the speed of the animation ( 1 is 100%.)1
segmentsAn array of two integers indicating the beginning and ending frame of the animationDefaults to play entire animation
forceSegmentsA boolean indicating wether the segments should play immediately or sequentiallyfalse
directionAn integer indicating wether the animation progresses in the usual (1) or reverse (-1) direction1
ariaRoleA string indicating the animation container ariaRole property"button"
ariaLabelA string indicating the animation container ariaLabel property"animation"
titleA string indicating the animation container title property""

Options object

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

Either the animationData OR path must be specified.

PropDescriptionDefault
animationDataMandatory - The source of the animation.
pathMandatory - The path to the animation.
assetsPathMandatory - The root path for external assets.images
loopPlay animation non-stop in a loop.true
autoplayAutomatically play animation when it is instantiated.true
rendererThe method for rendering the animation.svg
rendererSettingsCustomize bodymovin aspect ratio configurations.

Changing animation at runtime

You can target an specific After Effects layer property and change it at runtime by passing setting a property object on the <Lottie> prop. Example:

import React from 'react';
import Lottie from 'lottie-react-web'
import animation from './animation.json'

const Animation = ({ x, y }) => (
  <Lottie
    options={{
      animationData: animation,
    }}
    animationControl={{
      'Square,Transform,Position': [x, y],
    }}
  />
)

export default Animation

This will override the Position value of the layer JoyStkCtrl01 at runtime.

Lottie is compatible with Joystick 'n Sliders After Effects plugin, so you can create amazing animations easily.