JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.js"></script>
<div id="app">
<div class="circle" :style="style"></div>
</div>
CSS
body {
overflow: hidden;
}
.circle {
display: inline-block;
width: 50px;
height: 50px;
background: red;
border-radius: 50%;
position: absolute;
transform: translate(-50%, -50%);
}
JavaScript
new Vue({
el: '#app',
data: () => ({
coords: [ 0, 0 ],
}),
computed: {
style() {
return {
left: this.coords[0] + 'px',
top: this.coords[1] + 'px',
};
},
},
created() {
document.addEventListener('mousemove', e => this.coords = [ e.pageX, e.pageY ]);
},
});