Skip to content

Instantly share code, notes, and snippets.

@matthewsimo
Created July 28, 2023 22:10
Show Gist options
  • Save matthewsimo/ad6b3d3c5f9e2d42f7e0c9225e652d28 to your computer and use it in GitHub Desktop.
Save matthewsimo/ad6b3d3c5f9e2d42f7e0c9225e652d28 to your computer and use it in GitHub Desktop.
Get all CSS Custom Properties for root
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