acces css var with js code example Example: js set css variable document.documentElement.style.setProperty("--main-background-color", "green");