<div class="first-section">
  <h1 style="text-align: center">Toggle animation</h1>
</div>

<div style="width: 30%; height: 30%; justify-content: center; align-items: center; margin: auto">
  <lottie-player
                 id="firstLottie"
                 src="https://assets8.lottiefiles.com/private_files/lf30_tnblylie.json"
                 style="border-color: red; border-style: solid; border-width: 5px"
  >
  </lottie-player> 
</div>
@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono&display=swap');

.first-section {
 background-color: white;
}

.second-section {

  height: 100vh;
  width: 100%;
 background-color: white; 
}

.third-section {
  height: 100vh;
  width: 100%;
 background-color: white;  
}

h1 {
font-family: 'Roboto Mono', monospace;
}


.my-font {
font-family: 'Roboto Mono', monospace;
}
let player = document.getElementById("firstLottie");

player.addEventListener("ready", () => {
LottieInteractivity.create({
    player: "#firstLottie",
    mode:"cursor", 
    actions: [ {
      type: "toggle"
    }
    ]
});
});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://unpkg.com/@lottiefiles/[email protected]/dist/lottie-player.js
  2. https://unpkg.com/@lottiefiles/[email protected]/dist/lottie-interactivity.min.js