Last active
June 9, 2018 09:11
-
-
Save rkaneko/9548a4330c485e8fbc12b9bdabb44fb6 to your computer and use it in GitHub Desktop.
Get CSS custom property value by name via JavaScript.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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