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.

Revisions

  1. matthewsimo created this gist Jul 28, 2023.
    10 changes: 10 additions & 0 deletions get-css-custom-properties.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    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}`)
    }