<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: CapiLabs</title>
    <description>The latest articles on DEV Community by CapiLabs (@capilabs).</description>
    <link>https://dev.to/capilabs</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4164320%2Fe3b89aa0-f850-416f-bd44-2f05f0bd46f5.png</url>
      <title>DEV Community: CapiLabs</title>
      <link>https://dev.to/capilabs</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/capilabs"/>
    <language>en</language>
    <item>
      <title>How I Built a Modern Design Token Extractor: Solving CORS, Shadow DOM, and W3C DTCG Specs</title>
      <dc:creator>CapiLabs</dc:creator>
      <pubDate>Tue, 13 Oct 2026 12:25:26 +0000</pubDate>
      <link>https://dev.to/capilabs/how-i-built-a-modern-design-token-extractor-solving-cors-shadow-dom-and-w3c-dtcg-specs-6ah</link>
      <guid>https://dev.to/capilabs/how-i-built-a-modern-design-token-extractor-solving-cors-shadow-dom-and-w3c-dtcg-specs-6ah</guid>
      <description>&lt;p&gt;How I Built a Modern Design Token Extractor: Solving CORS, Shadow DOM, and W3C DTCG Specs&lt;/p&gt;

&lt;p&gt;Extracting design tokens from live websites sounds simple on paper—until you actually try to build a tool that handles modern frontend architectures. &lt;/p&gt;

&lt;p&gt;When working on &lt;strong&gt;Token Inspector&lt;/strong&gt;, my Chrome extension designed to bridge the gap between live web styles, Tailwind CSS, Figma (Tokens Studio), and Shadcn UI, I quickly ran into deep architectural walls. Traditional scrapers and basic CSS parsers fall apart the moment they encounter external CDNs, cross-origin security errors, or encapsulated web components.&lt;/p&gt;

&lt;p&gt;In this article, I want to share how I solved these bottlenecks in the latest v2 update, handling everything from strict W3C standards to Shadow DOM traversal.&lt;/p&gt;




&lt;h3&gt;
  
  
  1. The Trap of window.getComputedStyle() vs. Live Stylesheets
&lt;/h3&gt;

&lt;p&gt;Most quick scripts rely on &lt;code&gt;window.getComputedStyle()&lt;/code&gt; to grab colors, spacing, and font sizes from DOM elements. While easy, this approach has a massive flaw: &lt;strong&gt;it flattens the values&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;If a button uses &lt;code&gt;background-color: var(--primary-500)&lt;/code&gt;, &lt;code&gt;getComputedStyle&lt;/code&gt; returns the resolved computed color (e.g., &lt;code&gt;rgb(37, 99, 235)&lt;/code&gt;). You completely lose the semantic relationship and alias links like &lt;code&gt;{colors.primary.500}&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Solution:&lt;/strong&gt;&lt;br&gt;
To preserve raw variables and aliases, the parser must iterate directly through &lt;code&gt;document.styleSheets&lt;/code&gt; and inspect live CSS rules (&lt;code&gt;cssRules&lt;/code&gt;). This allows the extension to capture raw strings like &lt;code&gt;var(--token-name)&lt;/code&gt; and map them back to proper DTCG alias syntax.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Bypassing CORS Errors Gracefully
&lt;/h3&gt;

&lt;p&gt;Reading live stylesheets comes with a catch: if a website loads styles from an external CDN or Google Fonts (a different origin), the browser throws a strict &lt;code&gt;SecurityError&lt;/code&gt; due to CORS policies. &lt;/p&gt;

&lt;p&gt;If your parser isn't armored, a single third-party stylesheet will crash your entire extraction loop.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Solution:&lt;/strong&gt;&lt;br&gt;
We wrapped the stylesheet traversal in robust &lt;code&gt;try/catch&lt;/code&gt; blocks per sheet. If a stylesheet is completely unreachable due to strict CORS policies, it is skipped gracefully without breaking the main extraction thread:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (const sheet of document.styleSheets) {
  try {
    const rules = sheet.cssRules;
    // Process rules...
  } catch (e) {
    // Gracefully handle cross-origin stylesheets without crashing
    console.warn("Skipping cross-origin stylesheet due to CORS restrictions.");
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  3. Conquering Shadow DOM and Lit Components
&lt;/h3&gt;

&lt;p&gt;Modern component-based frameworks (like Lit, Shoelace, or custom web components) encapsulate their styles inside a &lt;strong&gt;Shadow DOM&lt;/strong&gt; using &lt;code&gt;adoptedStyleSheets&lt;/code&gt; on each shadow root. Standard &lt;code&gt;document.styleSheets&lt;/code&gt; is completely blind to these.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Solution:&lt;/strong&gt;&lt;br&gt;
To ensure zero tokens are left behind, the scanner performs a &lt;strong&gt;recursive traversal&lt;/strong&gt; through all open shadow roots (&lt;code&gt;shadowRoot&lt;/code&gt; with &lt;code&gt;mode: 'open'&lt;/code&gt;) across the DOM tree, harvesting their &lt;code&gt;adoptedStyleSheets&lt;/code&gt; alongside global rules:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function scanElement(element) {
  if (element.shadowRoot) {
    // Inspect adoptedStyleSheets inside the shadow root
    for (const sheet of element.shadowRoot.adoptedStyleSheets || []) {
      processRules(sheet.cssRules);
    }
    // Recursively check children inside shadow DOM
    scanSubTree(element.shadowRoot);
  }
  // Continue traversal...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;(Note: Closed shadow roots remain intentionally invisible by browser design, but open roots cover the vast majority of modern component libraries).&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Standardizing Output: W3C DTCG 2025.10 &amp;amp; Shadcn UI
&lt;/h3&gt;

&lt;p&gt;With clean raw data captured, the extension formats the output to match modern ecosystem standards:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;W3C DTCG 2025.10 Spec:&lt;/strong&gt; Colors are no longer dumped as flat hex strings. They are mapped into structured objects containing &lt;code&gt;colorSpace&lt;/code&gt;, &lt;code&gt;components&lt;/code&gt;, &lt;code&gt;alpha&lt;/code&gt;, and &lt;code&gt;hex&lt;/code&gt; properties, making them natively compatible with advanced token managers like Figma Tokens Studio.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Shadcn UI &amp;amp; Tailwind:&lt;/strong&gt; Automatically maps extracted variables to standard &lt;code&gt;--background&lt;/code&gt;, &lt;code&gt;--foreground&lt;/code&gt;, and &lt;code&gt;--primary&lt;/code&gt; variables, complete with light/dark mode separation and fallback heuristics.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Conclusion &amp;amp; Try Token Inspector&lt;br&gt;
Building developer tools requires anticipating edge cases where the browser's security model and modern component architecture collide. By combining direct stylesheet parsing, safe CORS handling, and recursive Shadow DOM crawlers, Token Inspector turns messy live DOMs into clean, production-ready design systems in seconds.&lt;/p&gt;

&lt;p&gt;If you are building design systems or juggling Tailwind and Figma syncs, you can install the extension right now:&lt;/p&gt;

&lt;p&gt;📥 &lt;a href="https://chromewebstore.google.com/detail/token-inspector-%E2%80%94-ui-desi/ahhkpfngdhkjiipkhfnefpkiniliafdh?hl=es&amp;amp;authuser=0" rel="noopener noreferrer"&gt;https://chromewebstore.google.com/detail/token-inspector-%E2%80%94-ui-desi/ahhkpfngdhkjiipkhfnefpkiniliafdh?hl=es&amp;amp;authuser=0&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(Looking for the Pro features? You can grab your license on &lt;a href="https://matyoro.gumroad.com/l/token-inspector?_gl=1*p1bw03*_ga*NzE5ODkxODI3LjE3OTA4NjIwNTY.*_ga_6LJN6D94N6*czE3OTE4NDA5NzUkbzQyJGcxJHQxNzkxODQxNDQ4JGo2MCRsMCRoMA" rel="noopener noreferrer"&gt;https://matyoro.gumroad.com/l/token-inspector?_gl=1*p1bw03*_ga*NzE5ODkxODI3LjE3OTA4NjIwNTY.*_ga_6LJN6D94N6*czE3OTE4NDA5NzUkbzQyJGcxJHQxNzkxODQxNDQ4JGo2MCRsMCRoMA&lt;/a&gt;.. and use the code REDDITPRO at checkout for an exclusive developer discount!)&lt;/p&gt;

&lt;p&gt;I’d love to hear your thoughts or how you handle token synchronization in your own tech stacks in the comments below!&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>css</category>
      <category>frontend</category>
      <category>webdev</category>
    </item>
    <item>
      <title>I built a Chrome Extension to extract Tailwind &amp; Figma tokens (and got blocked by Reddit bots 🤖)</title>
      <dc:creator>CapiLabs</dc:creator>
      <pubDate>Tue, 06 Oct 2026 12:54:37 +0000</pubDate>
      <link>https://dev.to/capilabs/i-built-a-chrome-extension-to-extract-tailwind-figma-tokens-and-got-blocked-by-reddit-bots--1cgg</link>
      <guid>https://dev.to/capilabs/i-built-a-chrome-extension-to-extract-tailwind-figma-tokens-and-got-blocked-by-reddit-bots--1cgg</guid>
      <description>&lt;p&gt;As someone who constantly jumps between UI/UX design in Figma and writing Tailwind components, I was wasting hours manually inspecting computed CSS to extract hex codes and build tailwind.config.js files.&lt;/p&gt;

&lt;p&gt;Over the weekend, I built Token Inspector, a 100% client-side Chrome extension to automate this. In one click, it exports ready-to-use Tailwind configs, Tokens Studio JSON, and zips all inline SVGs.&lt;/p&gt;

&lt;p&gt;I tried sharing it on Reddit this morning to get my first 20 users, but the automods instantly nuked my post because of the link. So, I’m giving the promo code I made for them to the Dev.to community instead.&lt;/p&gt;

&lt;p&gt;Use code REDDITPRO at checkout to bypass the paywall and get the premium version 100% free.&lt;/p&gt;

&lt;p&gt;You can grab it from the Chrome Web Store here:  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://chromewebstore.google.com/detail/token-inspector-%E2%80%94-ui-desi/ahhkpfngdhkjiipkhfnefpkiniliafdh?ref=producthunt" rel="noopener noreferrer"&gt;https://chromewebstore.google.com/detail/token-inspector-%E2%80%94-ui-desi/ahhkpfngdhkjiipkhfnefpkiniliafdh?ref=producthunt&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Let me know what you think of the code output!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>figma</category>
      <category>tailwindcss</category>
    </item>
    <item>
      <title>How to Extract Tailwind CSS Configs and Figma Tokens from Any Site in 1 Click</title>
      <dc:creator>CapiLabs</dc:creator>
      <pubDate>Mon, 05 Oct 2026 15:58:24 +0000</pubDate>
      <link>https://dev.to/capilabs/how-to-extract-tailwind-css-configs-and-figma-tokens-from-any-site-in-1-click-25hh</link>
      <guid>https://dev.to/capilabs/how-to-extract-tailwind-css-configs-and-figma-tokens-from-any-site-in-1-click-25hh</guid>
      <description>&lt;p&gt;Every developer and designer has been there: you stumble upon a beautifully designed website and want to reverse-engineer its design tokens or inspect how its typography, color palette, and utility classes are structured.&lt;/p&gt;

&lt;p&gt;Normally, this means opening DevTools, inspect-elementing dozens of DOM nodes one by one, manually copying computed HEX codes or CSS &lt;code&gt;--variables&lt;/code&gt;, and spending 30 minutes manually formatting a &lt;code&gt;tailwind.config.js&lt;/code&gt; or syncing values into Figma.&lt;/p&gt;

&lt;p&gt;I got tired of this repetitive manual process, so I built a privacy-first browser tool to automate it: &lt;strong&gt;Token Inspector&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Problem with Manual Token Inspection
&lt;/h2&gt;

&lt;p&gt;Modern web apps rely heavily on utility-first frameworks like &lt;strong&gt;Tailwind CSS&lt;/strong&gt; or complex CSS custom properties. When inspect-elementing computed styles in DevTools:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Variables are scattered:&lt;/strong&gt; CSS variables are often spread across &lt;code&gt;:root&lt;/code&gt;, body tags, or dynamically injected stylesheets.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Framework Mismatch:&lt;/strong&gt; Converting raw CSS computed values back into structured framework syntax requires manual guesswork and mapping.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Asset Collection Friction:&lt;/strong&gt; Extracting inline SVG icons or vector assets requires right-clicking each DOM element, copying outer HTML, and creating individual &lt;code&gt;.svg&lt;/code&gt; files manually.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Automating Token Extraction
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Token Inspector&lt;/strong&gt; scans the DOM and active stylesheets of any web page directly in your browser, extracting three major design system components:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Production-Ready Tailwind CSS Configurations
&lt;/h3&gt;

&lt;p&gt;Instead of manually guessing color palettes, typography scales, or border-radius rules, the extension parses the computed theme variables and builds a structured &lt;code&gt;tailwind.config.js&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;brand&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#f0f9ff&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#0ea5e9&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="mi"&gt;900&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#0c4a6e&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="na"&gt;fontFamily&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;sans&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Inter&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sans-serif&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="na"&gt;borderRadius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;custom&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;12px&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Figma Tokens Studio JSON Export&lt;br&gt;
Bridging the gap between design and production code is always tricky. The extension outputs structured JSON matching the Tokens Studio schema, allowing you to import color palettes and variables directly into native Figma Variables.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Bulk SVG Exporter&lt;br&gt;
It scans all inline vector elements (&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Privacy First: 100% Client-Side Architecture&lt;br&gt;
Security and privacy were top priorities when building this tool. Many web inspection extensions send scraped DOM nodes or telemetry to external backend servers.&lt;/p&gt;

&lt;p&gt;Token Inspector executes 100% client-side using standard Web APIs (window.getComputedStyle, DOM Parsing, and Canvas APIs). Zero data leaves your local browser session.&lt;/p&gt;

&lt;p&gt;Try It Out &amp;amp; Share Your Feedback&lt;br&gt;
We just launched Token Inspector today on Product Hunt!&lt;/p&gt;

&lt;p&gt;If you are a frontend developer, UI/UX designer, or indie builder, I'd love for you to give it a spin, test it on complex production web apps, and let me know your thoughts or edge cases you encounter.&lt;/p&gt;

&lt;p&gt;👉 Check out Token Inspector on Product Hunt: &lt;a href="https://www.producthunt.com/posts/token-inspector" rel="noopener noreferrer"&gt;https://www.producthunt.com/posts/token-inspector&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What does your current design token inspection workflow look like? Let's discuss in the comments below!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>tailwindcss</category>
      <category>css</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
