Gathering detailed insights and metrics for lottie-web-vue
Gathering detailed insights and metrics for lottie-web-vue
Gathering detailed insights and metrics for lottie-web-vue
Gathering detailed insights and metrics for lottie-web-vue
Lottie-web-vue is an Airbnb Lottie-web component for Vue.js projects that makes it easy for you to import lottie-web animations saved as .json format into your vue.js projects.
npm install lottie-web-vue
Typescript
Module System
Node Version
NPM Version
Vue (47.84%)
CSS (20.92%)
TypeScript (20.11%)
HTML (5.76%)
JavaScript (5.37%)
Total Downloads
1,832,639
Last Day
3,100
Last Week
20,085
Last Month
90,503
Last Year
778,431
MIT License
66 Stars
31 Commits
12 Forks
1 Watchers
1 Branches
3 Contributors
Updated on Jun 29, 2025
Latest Version
2.0.7
Package Id
lottie-web-vue@2.0.7
Unpacked Size
734.17 kB
Size
169.78 kB
File Count
10
NPM Version
8.5.0
Node Version
16.14.2
Published on
Jun 18, 2023
Cumulative downloads
Total Downloads
Last Day
48.7%
3,100
Compared to previous day
Last Week
2.6%
20,085
Compared to previous week
Last Month
21.4%
90,503
Compared to previous month
Last Year
27.6%
778,431
Compared to previous year
3
5
Airbnb's Lottie-web is a library for rendering animations exported from Adobe After Effects using the BodyMovin plugin. This package allows you to easily import animation files (available in .json format) into your Vue.js project.
With latest lottie-web-vue 2.x.x
release the library now supports Vue 3 + Typescript typing! If you are using Vue 2.x ensure to use version 1.2.1 (see below)
1npm install lottie-web-vue
Please install v1.2.1
of the plugin. This plugin will focus on maintaining Vue 3 now that it has been officially released.
1npm install lottie-web-vue@1.2.1
You can browse and download animations from LottieFiles. First, find an animation you like > signup > click export JSON
and save to your project. In vue you can save these under assets
and then use require('@/assets/animation.json')
to load them into the LottieAnimator
as part of the lottie-web-vue
component.
Example: https://lottiefiles.com/38726-stagger-rainbow
Add lottie-web-vue to your Vue 3.x project package using:
1npm install --save lottie-web-vue
or
yarn add lottie-web-vue
To use Vue 2.x use:
1npm install lottie-web-vue@1.2.1
Please install v1.2.1
of the plugin (this will no longer be maintained)
1import Vue from 'vue' 2import LottieAnimation from 'lottie-web-vue' 3 4Vue.use(LottieAnimation); // add lottie-animation to your global scope 5 6new Vue({ 7 render: h => h(App) 8}).$mount('#app')
Basic:
1<script setup lang="ts"> 2 import { onMounted, ref } from "vue" 3 import { LottieAnimation } from "lottie-web-vue" 4 import WatermelonJSON from "./assets/watermelon.json" 5 6 let anim = ref() 7 8 onMounted(() => { 9 setTimeout(() => { 10 console.log(anim.value.goToAndPlay(150, true)) 11 anim.value 12 }, 500) 13 }) 14</script> 15<template> 16 <LottieAnimation 17 :animation-data="WatermelonJSON" 18 :auto-play="true" 19 :loop="true" 20 :speed="1" 21 ref="anim" /> 22</template>
Full available props and events:
1<script setup> 2 import { onMounted, ref } from "vue" 3import { LottieAnimation } from "lottie-web-vue" 4import WatermelonJSON from "./assets/watermelon.json" 5 6let anim = ref() 7 8onMounted(() => { 9 setTimeout(() => { 10 console.log(anim.value.goToAndPlay(150, true)) 11 anim.value 12 }, 500) 13}) 14 15// called after each loop 16const loopComplete = () => { 17 console.log('Loop complete') 18} 19 20// called after first loop 21const complete = () => { 22 console.log('First loop complete') 23} 24 25// called after first frame entered 26const enterFrame = () => { 27 console.log('Entered first frame') 28} 29 30// called after segment started 31const segmentStart = () => { 32 console.log('Segment started') 33} 34 35// called after animation stopped 36const stopped = () => { 37 console.log('Stopped') 38} 39</script> 40<template> 41 <LottieAnimation 42 ref="anim" 43 :animation-data="WatermelonJSON" 44 :loop="true" 45 :auto-play="true" 46 :speed="1" 47 @loopComplete="loopComplete" 48 @complete="complete" 49 @enterFrame="enterFrame" 50 @segmentStart="segmentStart" 51 @stopped="stopped"/> 52</template>
The component has a number of props you can use to control the animation playback.
You must pass animationData to load the animation prior to the component being played.
Type: Object
Required: true
Include animation data from an import or require statement that imports the .json
file from your assets folder. e.g. require('@/assets/animation.json')
(save you animation as a.json file and put under src/assets in your project)
Type: [Boolean, Number]
Required: false
Default: false
True
: Animation continously loops
False
: Animation plays only once
[number e.g. 3]
: Animation plays N number of times before stopping (pass an integer)
Type: Boolean
Required: false
Default: true
True
: Animation will play as soon as it has finished loading
False
: Animation will play only when you call this.$refs.lottieAnimation.play()
(see below for playback controls)
Type: Number
Required: false
Default: 1
The speed that the animation will play back.
You can listen for events emitted by the component by using the @
syntax, passing in the parent method you wish to trigger. For more documentation about the Lottie-web events see here.
Fired once a complete loop of the animation has occurred
Fired once the animation has completed (only fired when loop = false)
As each frame is played this event is fired. Warning - this fires very frequently.
Event is fired when the animation enters each animation segment.
Playing the animation using goToAndStop()
function will raise an event once the animation has stopped at the designated frame.
You can call animation playback methods directly on the component if you wish to trigger playback on an event (i.e. when a user clicks the button, play the animation). You need to use the this.$refs
syntax and give your LottieAnimation a ref
id to use in the this.$refs.[your-name-here]
.
1<script setup> 2 import { LottieAnimation } from "lottie-web-vue" 3 import WatermelonJSON from "./assets/watermelon.json" 4</script> 5<template> 6 <LottieAnimation 7 ref="anim" 8 :animationData="animation" 9 /> 10</template>
Once your component (in the parent view) has a ref
id you can then use this in a method of your choosing:
1... // in your parent .vue file 2<script setup lang="ts"> 3 const buttonClicked = () => { 4 this.$refs.anim.play() // .play, .pause, .stop available 5 } 6</script>
Using this.$refs.anim.play()
will play the animation.
Using this.$refs.anim.pause()
will pause the animation.
Using this.$refs.anim.stop()
will stop the animation.
Using this.$refs.anim.setSpeed(2)
you can set the playback speed to 2
. Default speed is set to 1.
Using this.$refs.anim.goToAndStop(10, true
you can set the specific frame you wish the animation to stop at. Pass in the frame number or seconds to play and if the first value is a frame or a time as true/false. This function will raise an emit (add @stopped="Yourfunction()" to your lottie-animation listen for it).
Using this.$refs.anim.goToAndPlay(50, true)
allows you to specify the start time of the animation in either frame number (passing isFrame true/false if value is a frame or in seconds).
Using this.$refs.anim.setDirection(-1)
you can reverse your animation. You can pass in either AnimationDirection.
to reverse the animation or 1
to play forwards. Default playback is 1
.
Using this.$refs.anim.getDuration(true)
you can retrieve the current duration of the animation in frames or seconds (false). If you pass true, function returns duration in frames, if false, duration is passed back in seconds. Default is false (returned in seconds).
Using this.$refs.anim.destroy()
you can destroy the animation from the DOM.
See here for an example:
1<template> 2 <div id="app"> 3 <LottieAnimation 4 ref="anim" 5 :animationData="require('@/assets/animation.json')" 6 :loop="true" 7 :autoPlay="true" 8 @loopComplete="loopComplete" 9 @complete="complete" 10 @enterFrame="enterFrame" 11 /> 12 </div> 13</template> 14 15<script> 16import LottieAnimation from 'lottie-web-vue' 17 18export default { 19 components: { 20 LottieAnimation 21 }, 22 mounted() { 23 this.$refs.anim.play() 24 }, 25 methods: { 26 loopComplete() { 27 console.log('loopComplete') 28 }, 29 complete() { 30 console.log('complete') 31 }, 32 enterFrame() { 33 console.log('enterFrame') 34 } 35 } 36} 37</script>
To use this in a Vue 3 project that uses the setup
Composition API use the following:
1<script setup lang="ts"> 2import { onMounted, ref } from "vue" 3import { LottieAnimation } from "lottie-web-vue" 4import WatermelonJSON from "./assets/watermelon.json" 5 6let anim = ref() 7 8onMounted(() => { 9 setTimeout(() => { 10 console.log(anim.value.goToAndPlay(150, true)) 11 anim.value 12 }, 500) 13}) 14 15</script> 16<template> 17 <LottieAnimation 18 ref="anim" 19 :animation-data="WatermelonJSON" 20 :loop="true" 21 :auto-play="true" 22 :speed="1" 23 @loopComplete="loopComplete" 24 @complete="complete" 25 @enterFrame="enterFrame" 26 @segmentStart="segmentStart" 27 @stopped="stopped"/> 28</template>
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 2/28 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
16 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More