Plus · Lottie Animation
Lottie Animation
Display Lottie animation on the web page
When to use
The Lottie component can render Lottie animations conveniently and simply, and provides a way to obtain global Lottie and animation instances to meet a wider range of configuration needs.
lottie-web
is used internally to render Lottie animations. Compared to using lottie-web
directly, use the Semi Lottie component - No need to worry about the creation and destruction of animation containers
- No need to worry about the life cycle of the animation itself
- Easier to use with React projects
Demos
How to import
Lottie component supported from v2.62.0
Basic Usage
When the Lottie animation resource JSON is on CDN
Pass path=your lottie json URL to the
params
propsWhen Lottie animation resource JSON needs to be packaged into the website code
Pass animationData=your lottie json object into the
params
props (the Demo request JSON below is only for demonstration. In actual projects, json should be manually imported instead of obtained through network requests, so that JSON animation resources can be packaged into the website code)Params Other common parameters
params
will be passed to lottie.loadAnimation
of lottie-web
by the component. Please refer to lottie-web
documentationCommon parameters
Get the current animation instance
Use
getAnimationInstance
to get the animation instance of the currently playing animation. The instance contains many methods for adjusting various parameters of the animation, such as playing and pausing, getting the current frame number, adjusting the playback speed, etc.For more information about the methods contained in the animation instance, please refer to the
lottie-web
documentationGet global Lottie
Use
getLottie
Props to get global lottie, or use the static method Lottie.getLottie
on the Semi Lottie component to get global lottieFor more information about the methods on the global lottie, please refer to the
lottie-web
documentationAPI
Property | Description | Type | Default value |
---|---|---|---|
className | Class name | string | - |
params | Used to configure animation related parameters | Same as lottie-web lottie.loadAnimation input | - |
getAnimationInstance | Get the current animation AnimationItem | (animation:AnimationItem)=>void | - |
getLottie | Get the global Lottie | (lottie: Lottie)=>void | - |
style | Style | CSSProperties | - |