JSFiddle - React, Tailwind, and code Playground

HTML

<div id="d1"></div>

CSS

div {
    height: 10px;
    width: 10px;
    background-color: red;
    position: absolute;
}

JavaScript

var el = document.getElementById('d1');
document.addEventListener('mousemove', function(e) {
    setTimeout(function() {
        el.style.top = e.clientY + "px";
        el.style.left = e.clientX + "px";
    }, 200);
})