1var root = document.querySelector(':root');
2root.style.setProperty('--variable', 'lightblue');
3/or/
4root.style.setProperty('--variable', myColor);
1document.documentElement.setAttribute("style", "--main-background-color: green");
1document.documentElement.style.setProperty("--main-background-color", "green");
2
1let root = document.documentElement;
2
3root.addEventListener("mousemove", e => {
4 root.style.setProperty('--mouse-x', e.clientX + "px");
5 root.style.setProperty('--mouse-y', e.clientY + "px");
6});