Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lottiefiles/react-lottie-player

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lottiefiles/react-lottie-player

Lottie web player wrapper for React

  • 3.6.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is @lottiefiles/react-lottie-player?

@lottiefiles/react-lottie-player is a React component library that allows you to easily integrate Lottie animations into your React applications. It provides a simple and flexible way to control Lottie animations, including playing, pausing, stopping, and looping animations.

What are @lottiefiles/react-lottie-player's main functionalities?

Basic Animation Playback

This feature allows you to play a Lottie animation automatically and loop it. The `autoplay` and `loop` props control the playback behavior, and the `src` prop specifies the URL of the Lottie animation file.

import { Player } from '@lottiefiles/react-lottie-player';

function App() {
  return (
    <Player
      autoplay
      loop
      src="https://assets7.lottiefiles.com/packages/lf20_5x8LBM.json"
      style={{ height: '300px', width: '300px' }}
    />
  );
}

Controlling Animation Playback

This feature allows you to control the playback of a Lottie animation using buttons. The `ref` prop is used to get a reference to the Player component, which is then used to call the `play`, `pause`, and `stop` methods.

import { Player } from '@lottiefiles/react-lottie-player';
import { useRef } from 'react';

function App() {
  const playerRef = useRef(null);

  return (
    <div>
      <Player
        ref={playerRef}
        src="https://assets7.lottiefiles.com/packages/lf20_5x8LBM.json"
        style={{ height: '300px', width: '300px' }}
      />
      <button onClick={() => playerRef.current.play()}>Play</button>
      <button onClick={() => playerRef.current.pause()}>Pause</button>
      <button onClick={() => playerRef.current.stop()}>Stop</button>
    </div>
  );
}

Customizing Animation Speed

This feature allows you to customize the playback speed of a Lottie animation. The `setPlayerSpeed` method is used to set the speed of the animation, with 1 being the normal speed.

import { Player } from '@lottiefiles/react-lottie-player';
import { useRef } from 'react';

function App() {
  const playerRef = useRef(null);

  return (
    <div>
      <Player
        ref={playerRef}
        src="https://assets7.lottiefiles.com/packages/lf20_5x8LBM.json"
        style={{ height: '300px', width: '300px' }}
      />
      <button onClick={() => playerRef.current.setPlayerSpeed(0.5)}>0.5x Speed</button>
      <button onClick={() => playerRef.current.setPlayerSpeed(1)}>1x Speed</button>
      <button onClick={() => playerRef.current.setPlayerSpeed(2)}>2x Speed</button>
    </div>
  );
}

Other packages similar to @lottiefiles/react-lottie-player

Keywords

FAQs

Package last updated on 14 Jan 2025

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