Vue Player
Learn how to integrate the dotLottie Vue component into your Vue.js application. This guide covers installation and basic usage.
Getting Started with the Vue Player
In this tutorial, you will install and configure the Vue player to display your first Lottie animation in a Vue.js application.
Prerequisites
Working Vue.js development environment (Vue 3 recommended, using Vite, Vue CLI, etc.).
Node.js and npm or yarn installed.
Installation
Install the package using your preferred package manager:
# Using npm
npm install @lottiefiles/dotlottie-vue
# Using yarn
yarn add @lottiefiles/dotlottie-vueBasic Usage Example
Here's a simple Vue Single File Component (SFC) demonstrating how to import and use the player:
<template>
<div>
<h2>My Vue Animation</h2>
<DotLottieVue class="my-lottie-player" // Optional: Add classes for styling
src="https://lottie.host/your-animation-id.lottie" // Replace with your
animation URL :autoplay="true" :loop="true" style="width: 300px; height:
300px;" // Optional: control size />
</div>
</template>
<script>
import { DotLottieVue } from "@lottiefiles/dotlottie-vue";
export default {
name: "AnimationComponent", // Good practice to name components
components: {
DotLottieVue,
},
};
</script>
<style scoped>
/* Optional: Style the container */
.my-lottie-player {
/* width: 300px; */ /* Example size in <template> */
/* height: 300px; */
border: 1px solid #eee;
}
</style>Explanation:
Import: Import
DotLottieVuewithin the<script>block.Register: Register it in the
componentsoption (if using Options API).Use: Render the
<DotLottieVue />component in the<template>.Props:
src: Required URL or path to your.lottieor.jsonfile.:autoplay="true": Binds theautoplayprop totrue(use:orv-bind:for dynamic values/booleans).:loop="true": Binds theloopprop totrue.style: Standard Vue style binding for sizing and appearance.class: Standard Vue class binding.
Automatic Cleanup
The component generally handles calling destroy() on the core player instance when the Vue component is unmounted.
Next Steps
Explore Props: Check out the complete Props Reference.
See Examples: Learn how to control playback and handle events in the Examples.
Advanced Usage: Find details on more advanced topics in Advanced Usage.