To change CSS :root color variables in JavaScript, we call the setProperty
method.
For instance, we write
document.documentElement.style.setProperty("--your-variable", "#FFF");
to call setProperty
to define the --your-variable
variable and set it to '#FFF'
.