DEV Community

loading...

Discussion on: CSS Variables

Collapse
samanthaming profile image
Samantha Ming Author • Edited

Great question @clozach ! You will have to go with the getComputedStyle route, but instead of passing the element, you just pass in document.documentElement. So something like this:

:root {
  --color: red;
}
getComputedStyle(document.documentElement).getPropertyValue('--color');

(Let me update my official notes too 👏)