Skip to content

Instantly share code, notes, and snippets.

@Fintan
Last active December 13, 2019 09:58
Show Gist options
  • Save Fintan/41829555bb38a67fca178ac54bbeaf07 to your computer and use it in GitHub Desktop.
Save Fintan/41829555bb38a67fca178ac54bbeaf07 to your computer and use it in GitHub Desktop.
get hexadecimal string from a css var
// see https://codesandbox.io/s/epic-cherry-p6hw0
const computedStyle = getComputedStyle(document.documentElement);
const primaryColour = computedStyle.getPropertyValue("--primary-colour").trim(); // outputs #00ff00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment