Skip to content

Instantly share code, notes, and snippets.

@rkaneko
Last active June 9, 2018 09:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rkaneko/9548a4330c485e8fbc12b9bdabb44fb6 to your computer and use it in GitHub Desktop.
Save rkaneko/9548a4330c485e8fbc12b9bdabb44fb6 to your computer and use it in GitHub Desktop.
Get CSS custom property value by name via JavaScript.
function getCustomProperty(name: string): string {
const style = window.getComputedStyle(document.documentElement);
return style.getPropertyValue(name).trim();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment