• Stars
    star
    112
  • Rank 312,240 (Top 7 %)
  • Language Vue
  • Created about 4 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Lottie player wrapper for Vue.js

LottiePlayer Vue Component

This is a Vue component for the Lottie Web Player. This library is a vue wrapper around the LottieFiles Lottie Web Player

screencast

In Javascript or TypeScript:

  1. Install package using npm or yarn.
npm install --save @lottiefiles/vue-lottie-player
  1. Import package in your code.
import LottieVuePlayer from "@lottiefiles/vue-lottie-player";
  1. Add the player as a plugin to Vue
Vue.use(LottieVuePlayer);

With Nuxt:

  1. Install package using npm or yarn.
npm install --save @lottiefiles/vue-lottie-player
  1. Create a folder called 'plugins' at the root of your project

  2. Create a file named 'lottie-vue-player.client.js' inside the 'plugins' directory

  3. Inside this file put :

import Vue from 'vue';

import LottieVuePlayer from "@lottiefiles/vue-lottie-player";

Vue.use(LottieVuePlayer);
  1. Add to nuxt.config.js:
 plugins: [
    "~/plugins/lottie-vue-player.client.js"
  ]

Example/Development

  1. Clone repo

  2. run yarn install

Usage

Player component

Add the element lottie-vue-player and set the src prop to a URL pointing to a valid Lottie JSON. Full example of an App.vue file is shown below.

<template>
    <div id="app">
        <lottie-vue-player :src="`https://assets10.lottiefiles.com/packages/lf20_tzjfwgud.json`"
                           :theme="options.theme"
                           :player-size="options.playerSize"
                           :player-controls="true"
                           style="width: 100%; height:400px">
        </lottie-vue-player>
    </div>
</template>

<script>

    export default {
        name: 'App',
        data() {
            return {
                options: {
                    minimizable: false,
                    playerSize: "standard",
                    backgroundColor: '#fff',
                    backgroundStyle: 'color',
                    theme: {
                        controlsView: "standard",
                        active: "light",
                        light: {
                            color: '#3D4852',
                            backgroundColor: '#fff',
                            opacity: '0.7',
                        },
                        dark: {
                            color: '#fff',
                            backgroundColor: '#202020',
                            opacity: '0.7',
                        }
                    }
                }
            }
        }
    }
</script>

Props

Prop Description Type Default
autoplay Autoplay animation on load. boolean false
backgroundColor Background color. string undefined
playerControls Show controls. boolean false
showColorPicker Show color picker boolean false
playerSize Player set size (hide, minimal, standard) string standard
loop Whether to loop animation. boolean false
speed Animation speed. number 1
style The style for the container. object undefined
src (required) Bodymovin JSON data or URL to JSON. object string

Methods

togglePlayPause() => void

Toggle animation play pause.

Returns

Type: void

toggleFullscreen() => void

Toggle full screen player.

Returns

Type: void

toggleLoop() => void

Toggle animation loop.

Returns

Type: void

setPlayerSpeed(speed?: number) => void

Sets animation play speed.

Parameters

Name Type Description
value number Playback speed.

Returns

Type: void

stop() => void

Stops animation play.

Returns

Type: void

setBackgroundColor(color: string) => void

set background color.

Returns

Type: void

Contributing

We use changesets to maintain a changelog for this repository. When making any change to the codebase that impacts functionality or performance we require a changeset to be present.

To add a changeset run:

yarn run changeset

And select the type of version bump you'd like (major, minor, path).

You can document the change in detail and format it properly using Markdown by opening the ".md" file that the "yarn changeset" command created in the ".changeset" folder. Open the file, it should look something like this:

---
"@lottiefiles/pkg1": minor
"@lottiefiles/pkg2": major
---

This is where you document your **changes** using Markdown.

- You can write
- However you'd like
- In as much detail as you'd like

Aim to provide enough details so that team mates and future you can understand the changes and the context of the change.

You can commit your changes and the changeset to your branch and then create a pull request on the develop branch.

License

MIT License Β© LottieFiles.com

More Repositories

1

lottie-player

Lottie viewer/player as an easy to use web component! https://lottiefiles.com/web-player
TypeScript
1,539
star
2

lottie-react

lottie web player as a react component
TypeScript
718
star
3

lottie-interactivity

A small javascript library to enable interactivity with Lottie animations
HTML
428
star
4

awesome-lottie

A curated list of bookmarks, libraries, tools and resources related to Lottie and Bodymovin
306
star
5

jlottie

A small-footprint lottie player in Javascript
CSS
182
star
6

dotlottie-web

Official LottieFiles player for rendering Lottie and dotLottie animations in the web. Supports React, Vue, Svelte, SolidJS and Web Components.
TypeScript
155
star
7

dotlottie-rs

A universal, high-performance Lottie and dotLottie player built with Rust. Offers smooth rendering across platforms, low resource consumption, and extensive compatibility. Features FFI bindings for Kotlin, Swift, and WASM for seamless integration in Android, iOS, and Web projects.
Rust
147
star
8

lottie-js

An object model for representing and manipulating the Lottie JSON structure in JS.
TypeScript
143
star
9

svelte-lottie-player

Lottie Player component for Svelte
HTML
136
star
10

glottie

OpenGL/WebGL based Lottie animation player
C++
117
star
11

tgskit

Toolkit for dealing with Telegram Stickers and Bodymovin/Lottie animations.
TypeScript
62
star
12

relottie

Lottie processor powered by plugins
TypeScript
45
star
13

lottie-docs

Documentation for the lottie file format
Python
45
star
14

dotlottie-ios

.lottie player for iOS
C
41
star
15

dotlottie-android

Kotlin
37
star
16

svg-to-lottie-converter

SVG to Lottie API
Python
25
star
17

demo-audio-visualisation

Demonstration code for visualising audio with Lottie
C#
14
star
18

Course-for-Developers

In this quick course, you will learn the basics about implementing Lottie animations across your web and mobile apps.
10
star
19

lottie-theming

JavaScript
10
star
20

dotlottie-cs

C#
8
star
21

plugin-strapi

TypeScript
4
star
22

LottieNB

Simple insertion of Lottie player into Jupyter Notebooks
Jupyter Notebook
4
star
23

labs-epub3

Testing lottie support in an epub3 document
Shell
4
star
24

test-files

A collection of basic lotties to test lottie tooling
Python
3
star
25

lottie-styler

TypeScript
3
star
26

app-tutorial-lottieinteractions

A tutorial for Lottie Interactions
Swift
2
star
27

dotlottie-react-native

Kotlin
2
star
28

gltf-color

TypeScript
1
star