Socket
Socket
Sign inDemoInstall

lottie-react

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lottie-react

Lottie for React


Version published
Weekly downloads
549K
decreased by-9.93%
Maintainers
1
Weekly downloads
 
Created

What is lottie-react?

The lottie-react npm package is a React wrapper for Lottie animations, which allows you to easily integrate and control Lottie animations in your React applications. Lottie is a library for rendering Adobe After Effects animations in real-time, which are exported as JSON files using the Bodymovin plugin.

What are lottie-react's main functionalities?

Basic Animation

This feature allows you to render a basic Lottie animation in your React component. You simply import the Lottie component and the animation JSON file, then use the Lottie component with the animationData prop.

import React from 'react';
import Lottie from 'lottie-react';
import animationData from './path/to/animation.json';

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

export default BasicAnimation;

Controlled Animation

This feature allows you to control the playback of the Lottie animation. In this example, a button is used to toggle the animation between play and pause states using the isPaused prop.

import React, { useState } from 'react';
import Lottie from 'lottie-react';
import animationData from './path/to/animation.json';

const ControlledAnimation = () => {
  const [isPaused, setIsPaused] = useState(false);

  return (
    <div>
      <Lottie animationData={animationData} isPaused={isPaused} />
      <button onClick={() => setIsPaused(!isPaused)}>
        {isPaused ? 'Play' : 'Pause'}
      </button>
    </div>
  );
};

export default ControlledAnimation;

Looping Animation

This feature allows you to set the animation to loop continuously. By setting the loop prop to true, the animation will restart automatically after it finishes.

import React from 'react';
import Lottie from 'lottie-react';
import animationData from './path/to/animation.json';

const LoopingAnimation = () => {
  return <Lottie animationData={animationData} loop={true} />;
};

export default LoopingAnimation;

Event Listeners

This feature allows you to add event listeners to the Lottie animation. In this example, the onComplete event listener is used to log a message when the animation completes.

import React from 'react';
import Lottie from 'lottie-react';
import animationData from './path/to/animation.json';

const AnimationWithEvents = () => {
  const handleComplete = () => {
    console.log('Animation completed');
  };

  return <Lottie animationData={animationData} onComplete={handleComplete} />;
};

export default AnimationWithEvents;

Other packages similar to lottie-react

Keywords

FAQs

Package last updated on 19 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc