Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

lottie-animation

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lottie-animation

A React component for Lottie animations

latest
Source
npmnpm
Version
1.1.1
Version published
Weekly downloads
54
25.58%
Maintainers
1
Weekly downloads
 
Created
Source

LottieAnimation for React

LottieAnimation is a lightweight and straightforward React component for adding beautiful animations using Lottie files in your web project.

Features

  • Simple Integration: Easily embed Lottie animations.
  • Control Playback: Configurable loop and autoplay options.
  • Event Handling: Execute a callback function when the animation completes.
  • Styling: Apply custom styles and class names.
  • Clean Up: Automatic cleanup of animations to prevent memory leaks.

Installation

Install the package via npm:

npm install lottie-animation

or with yarn:

yarn add lottie-animation

Make sure you have react and prop-types installed in your project as they are peer dependencies of this component.

Usage

Import the LottieAnimation component in your React application and use it as follows:

import React from 'react';
import LottieAnimation from 'lottie-animation';

const MyComponent = () => {
  const onComplete = () => {
    console.log('Animation completed!');
  };

  return (
    <LottieAnimation
      animationPath="path-to-your-lottie.json"
      loop={true}
      autoplay={true}
      style={{ width: 200, height: 200 }}
      className="my-custom-class"
      onComplete={onComplete}
    />
  );
};

export default MyComponent;

Props

The following props are available to customize the LottieAnimation:

PropTypeDefaultDescription
animationPathstringRequired. The path to the Lottie JSON file.
loopbooleantrueDetermines if the animation should loop.
autoplaybooleantrueDetermines if the animation should start automatically.
styleobjectInline styles for the animation container.
classNamestringCSS class for the animation container.
onCompletefunctionCallback function when the animation completes.

Contributing

Contributions are always welcome!

License

Distributed under the MIT License. See LICENSE for more information.

Keywords

lottie

FAQs

Package last updated on 07 Nov 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