Mouse Tracking with CSS Variables

Use CSS Variables powered by a few lines of JavaScript to have elements follow the cursor.

codepen.io
js
const app = document.querySelector('#app');
document.body.addEventListener('mousemove', (event) => {
app.style.setProperty('--x', event.clientX);
app.style.setProperty('--y', event.clientY);
});