Giter VIP home page Giter VIP logo

react-lottie's Introduction

@crello/react-lottie

React/Typescript wrapper for awesome Airbnb's lottie-web lib.

Demo

https://crello.github.io/react-lottie/

you can find demo files in ./examples folder -- launch with yarn start

Installation

yarn add @crello/react-lottie or npm install --save @crello/react-lottie

Usage

Most basic react-lottie example:

import React from 'react';
import { Lottie } from '@crello/react-lottie'
import animationData from './myAwesomeAnimation.json'

export const BasicLottieComponent = () => <Lottie config={{animationData: animationData}}>

Lottie component creates <div> and passes it to lottie config as the container param. This div contains renderer's output of choosen type: 'svg'| 'html' | 'canvas'. <Lottie> accepts style and className props that will apply to the container.

Any browser events should be added on elements wrapping actual <Lottie> e.g.:

<div onClick={..}>
    <Lottie/>
<div>

Params

Props

{
  height?: string - valid css value e.g. '100px' [default: `100%`],
  width?: string - valid css value e.g. '100px' [default: `100%`],
  playingState?: 'playing' | 'stopped' | 'paused' [default: `playing`],
  segments?: AnimationSegment | AnimationSegment[],
  speed?: number - animation playback speed [default: `1`],
  style?: styles passed to lottie container,
  direction?: AnimationDirection - [default: `1`],
  lottieEventListeners?: ReactLottieEvent[] - see available events in AnimationEventName from 'lottie-web',
  config: ReactLottieConfig - config with mandatory `path` or `animationData`,
}

Config

{
  animationData: any - an Object with the exported animation data,
  path: string - remote data,
  renderer?: 'svg' | 'canvas' | 'html' - choose renderer [default: `svg`],
  loop?: boolean | number - loop boolean or count [default: `false`],
  autoplay?: boolean - it will start playing as soon as it is ready [default: `true`],
  name?: string - animation name for future reference,
  rendererSettings?: SVGRendererConfig | CanvasRendererConfig | HTMLRendererConfig,
}

More

See more details in @crello/react-lottie exports: Lottie, ReactLottieConfig, ReactLottieOwnProps, ReactLottiePlayingState

Also check out the types provided by lottie-web itself: AnimationDirection, AnimationSegment, AnimationEventName, AnimationEventCallback, AnimationItem, BaseRendererConfig, SVGRendererConfig, CanvasRendererConfig, HTMLRendererConfig, AnimationConfig, AnimationConfigWithPath, AnimationConfigWithData, Lottie

More lottie animations you can find on lottiefiles

License

MIT

react-lottie's People

Contributors

arvinh avatar babygoat avatar blakedietz avatar chenqingspring avatar dalerasrorov-eb avatar good-idea avatar jakeleboeuf avatar jchen-eb avatar jcrben avatar jwfwessels avatar lazysergey avatar oblador avatar ryanponce avatar sahajr avatar simchashats avatar timhau avatar tpae avatar yagolopez avatar

Watchers

 avatar  avatar

Forkers

reflexions

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.