npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@rolster/react-lottie

v19.4.0

Published

Package containing UI components for Lottie in React.

Downloads

275

Readme

Rolster React Lottie

Package containing UI components for Lottie in React.

Installation

npm i @rolster/react-lottie

react and react-dom are not declared as dependencies of this package: the consuming project must have them installed (React 19 typings are used).

Features

The package wraps lottie-web and exposes a component (default export), two hooks and their types.

Lottie component

Lottie is the default export. It renders a <div> container, loads the animation in it and, optionally, wires scroll/cursor interactivity. Its props are LottieComponentProps:

| Prop | Description | | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | | animationData | Parsed Lottie JSON (required). | | loop, autoplay, initialSegment | Playback options forwarded to lottie-web. loop and initialSegment are watched and applied on change. | | renderer, name, assetsPath, rendererSettings | Remaining lottie-web configuration. | | lottieRef | A LottieRef that receives the playback API (LottieRefCurrentProps) once the animation is loaded. | | onComplete, onLoopComplete, onEnterFrame, onSegmentStart, onConfigReady, onDataReady, onDataFailed, onLoadedImages, onDOMLoaded, onDestroy | lottie-web event listeners. | | interactivity | { mode: 'scroll' \| 'cursor'; actions: Action[] } to drive the animation from scroll position or cursor position. | | style and any other <div> HTML prop | Applied to the container element. |

import Lottie, { LottieRefCurrentProps } from '@rolster/react-lottie';
import { useRef } from 'react';
import animationData from './loader.json';

function Loader() {
  const lottieRef = useRef<LottieRefCurrentProps>(null);

  return (
    <Lottie
      animationData={animationData}
      loop
      lottieRef={lottieRef}
      style={{ width: 200, height: 200 }}
      onLoopComplete={() => lottieRef.current?.setSpeed(2)}
    />
  );
}

Interactivity example, seeking through frames 0–120 while the container scrolls into view:

<Lottie
  animationData={animationData}
  interactivity={{
    mode: 'scroll',
    actions: [{ type: 'seek', visibility: [0, 1], frames: [0, 120] }]
  }}
/>

useLottie(props, style?)

Named export. Receives LottieOptions (the component props minus interactivity) plus an optional CSSProperties object for the container and returns { View } & LottieRefCurrentProps: View is the ReactElement to render, and the rest is the playback API.

| Member | Description | | -------------------------------------------- | --------------------------------------------------------- | | View | Container element with the animation attached. | | play(), stop(), pause() | Playback control. | | setSpeed(speed), setDirection(direction) | Speed and direction (1 / -1). | | goToAndPlay(value, isFrame?) | Jump to a frame or time and play. | | goToAndStop(value, isFrame?) | Jump to a frame or time and stop. | | playSegments(segments, forceFlag?) | Play one or several [from, to] segments. | | setSubframe(useSubFrames) | Toggle subframe rendering. | | getDuration(inFrames?) | Duration in seconds (or frames); undefined before load. | | destroy() | Destroys the lottie-web instance. | | animationContainerRef | RefObject<HTMLDivElement \| null> of the container. | | animationLoaded | true once lottie-web created the animation. | | animationItem | The underlying AnimationItem, or undefined. |

import { useLottie } from '@rolster/react-lottie';
import animationData from './hero.json';

function Hero() {
  const { View, play, pause } = useLottie(
    { animationData, loop: true, autoplay: false },
    { height: 320 }
  );

  return (
    <section onMouseEnter={play} onMouseLeave={pause}>
      {View}
    </section>
  );
}

useLottieInteractivity({ actions, mode, lottieObj })

Named export. Takes InteractivityProps — the object returned by useLottie as lottieObj, the interactivity mode and the list of Actions — attaches the scroll or cursor listeners to the container and returns the View to render. Lottie uses it internally when interactivity is provided.

Types

| Type | Description | | ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | LottieOptions<T extends RendererType = 'svg'> | lottie-web AnimationConfigWithData without container, plus animationData, lottieRef, the on* listeners and <div> HTML props (except loop). | | LottieComponentProps | LottieOptions & { interactivity?: { mode; actions } } — props of Lottie. | | LottieRefCurrentProps | Playback API exposed through lottieRef and returned by useLottie. | | LottieRef | RefObject<LottieRefCurrentProps \| null>. | | InteractivityProps | { lottieObj; actions: Action[]; mode: 'scroll' \| 'cursor' } — argument of useLottieInteractivity. | | Action | { type: 'seek' \| 'play' \| 'stop' \| 'loop'; frames: [number] \| [number, number]; visibility?: [number, number]; position?: Position }. visibility applies to scroll mode, position to cursor. | | Position | { x: number \| [number, number]; y: number \| [number, number] } — relative (0–1) cursor coordinates or ranges. | | PartialLottieOptions, PartialLottieComponentProps | Same as the base types with animationData optional. |

Contributing

:sparkles: Daniel Andrés Castillo Pedroza