JSFiddle - React, Tailwind, and code Playground
HTML
<div class="box"></div>
CSS
.box{
background-color: black;
width: 100px;
height: 30px;
position: absolute;
left: 200px;
top: 200px;
}
JavaScript
var box=$(".box");
var boxCenter=[box.offset().left+box.width()/2, box.offset().top+box.height()/2];
$(document).mousemove(function(e){
var angle = Math.atan2(e.pageX- boxCenter[0],- (e.pageY- boxCenter[1]) )*(180/Math.PI);
box.css({ "-webkit-transform": 'rotate(' + angle + 'deg)'});
box.css({ '-moz-transform': 'rotate(' + angle + 'deg)'});
box.css({ 'transform': 'rotate(' + angle + 'deg)'});
});