Lottie for React
Edit page
Components
Hooks
useLottieGetting StartedParamsReturnsuseLottieInteractivity

useLottie

Getting Started

import { useLottie } from "lottie-react";
import groovyWalkAnimation from "./groovyWalk.json";
const style = {
height: 300,
};
const Example = () => {
const options = {
animationData: groovyWalkAnimation,
loop: true,
autoplay: true,
};
const { View } = useLottie(options, style);
return View;
};
export default Example;

Params

ParamTypeRequiredDefaultDescription
optionsObjectrequiredSubset of the lottie-web options
options.animationDataObjectrequiredA JSON Object with the exported animation data
options.loopboolean|numberoptionaltrueSet it to true for infinite amount of loops, or pass a number to specify how many times should the last segment played be looped (More info)
options.autoplaybooleanoptionaltrueIf set to true, animation will play as soon as it's loaded
options.initialSegmentarrayoptionalExpects an array of length 2. First value is the initial frame, second value is the final frame. If this is set, the animation will start at this position in time instead of the exported value from AE
styleObjectoptionalStyle object that applies to the animation wrapper (which is a div)

Returns

PropertyType
LottieObject
Lottie.ViewReact.Element
Lottie.playmethod
Lottie.stopmethod
Lottie.pausemethod
Lottie.setSpeedmethod
Lottie.goToAndStopmethod
Lottie.goToAndPlaymethod
Lottie.setDirectionmethod
Lottie.playSegmentsmethod
Lottie.setSubframemethod
Lottie.getDurationmethod
Lottie.destroymethod