Created
July 28, 2023 22:10
-
-
Save matthewsimo/ad6b3d3c5f9e2d42f7e0c9225e652d28 to your computer and use it in GitHub Desktop.
Get all CSS Custom Properties for root
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
let vars = new Map() | |
for (const [prop, val] of document.documentElement.computedStyleMap()) { | |
if (prop.startsWith('--')) { | |
vars.set(prop, val[0][0]) | |
} | |
} | |
for (const [k, v] of vars.entries()) { | |
console.log(`${k}: ${v}`) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment