JSFiddle - React, Tailwind, and code Playground

HTML

<div id="my-rotating-el"></div>

CSS

#my-rotating-el{
    background :red;
    height: 50px;
    width: 50px;
  }

JavaScript

const rotatingE = document.getElementById('my-rotating-el')
  document.addEventListener('mousemove', e => {
    const mX = e.clientX / window.innerWidth * 360

    rotatingE.style.transform = 'rotate('+ mX +'deg)'
  })