Skip to content

Instantly share code, notes, and snippets.

@nmanikiran
Created May 16, 2020 17:34
Show Gist options
  • Save nmanikiran/74941da50457fa68b448e0ce0d6b6403 to your computer and use it in GitHub Desktop.
Save nmanikiran/74941da50457fa68b448e0ce0d6b6403 to your computer and use it in GitHub Desktop.
Update CSS variables with javascript
var root = document.querySelector(':root');
var rootStyles = getComputedStyle(root);
var red = rootStyles.getPropertyValue('--red');
console.log('red: ', red);
root.style.setProperty('--red', 'green')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment