JSFiddle - React, Tailwind, and code Playground

HTML

<button class='anistop' id="stop">anistop</button>
<div class='block' id="block"></div>

CSS

.block {
  width: 10em;
  height: 10em;
  background: gray;
  margin: 20px;
  animation: rotate 10s infinite linear;
}

@keyframes rotate {
  100% {
    transform: rotateY(360deg);
  }
}

JavaScript

var state=true;
document.querySelector('#stop').onclick=()=>{
	block.style.animationPlayState=state?'paused':'running';
	state=!state;
};