CSS custom properties
The CSS parser extracts tokens from CSS custom properties declared inside a:root {} block.
Syntax
tokens.css
Name derivation
The-- prefix is stripped. The token name in the panel is the CSS custom property name without dashes: color-primary, space-1, etc.
Rules and limitations
- Only
:root {}is scanned. Tokens declared in other selectors (:host,[data-theme], media queries) are not loaded. - Values can be any valid CSS value string — colors, lengths, shadows, easing functions, etc.
- Multi-value properties are supported:
--shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05). - Comments inside
:rootare ignored. - Variables that reference other variables (e.g.
--color-bg: var(--color-neutral-50)) are loaded with the raw reference value.
Multiple :root blocks
Only the first :root {} block in the file is parsed. Tokens in a second :root {} block will not be loaded.
SCSS
SCSS files (.scss) are parsed with the same engine as CSS. The file must declare tokens as CSS custom properties inside a :root {} block. SCSS-specific syntax like variables ($var), nesting, and mixins is ignored — only CSS custom properties inside :root are extracted.
Syntax
tokens.scss
//) inside :root are handled correctly — they do not interfere with token extraction.
Rules and limitations
- The same constraints as CSS apply: only the first
:root {}block is parsed. - SCSS-only features (variables,
@mixin,@include, nesting) are not interpreted. Only CSS custom property lines (--name: value;) are extracted. - Remote
.scsssources are supported with the same constraints as remote CSS sources.
JSON
The JSON parser supports both flat and deeply nested objects. All values are flattened into a single token list.Flat JSON
tokens.json
Nested JSON
tokens.json
-. The above produces:
color-primarycolor-neutral-100color-neutral-500color-neutral-900space-1,space-2,space-4,space-8
Design Tokens format (W3C / Style Dictionary)
Many design tools export tokens in a nested format with a$value key. This is flattened like any other nested structure. The path segments (excluding $value) become the token name:
color-primary-$value (with value #7C3AED) and color-primary-$type (with value color). If you use this format, consider naming conventions that avoid $value in the token name — or configure a group to filter by prefix.
Rules and limitations
- Values must be strings or numbers. Arrays and booleans are skipped.
- Maximum nesting depth: 20 levels.
- Numbers are converted to strings (e.g.
400becomes"400"). - Parsing errors result in an empty token set with an error notification.
JavaScript / TypeScript (local files only)
The JS/TS parser uses regex to extract string and number variable assignments without executing any code.Syntax
tokens.ts
Name derivation
Variable names are used as-is (they are not converted to kebab-case). The token name in the panel matches the variable name:colorPrimary, spaceSm, fontWeightBold.
Rules and limitations
- Only single-line assignments are matched. Multi-line values are not supported.
- Values must be string literals (single quotes, double quotes, or backticks) or number literals.
- Complex expressions, function calls, template literals with interpolations, and object/array assignments are all ignored.
- TypeScript type annotations between
:and=are tolerated and stripped. - Remote JS/TS files are not supported. Only local workspace files can be loaded. This is a deliberate security constraint.
- Destructuring assignments and shorthand exports are not matched.
When to use JS/TS format
JS/TS loading is best for simple constant files that export primitive token values. If your token file is complex (uses imports, computed values, or factories), consider exporting a plain JSON file instead.Choosing a format
| Consideration | CSS | SCSS | JSON | JS/TS |
|---|---|---|---|---|
| Nesting support | — | — | Deep nesting | — |
| Remote loading | ✓ | ✓ | ✓ | — |
| Native CSS usage | ✓ | ✓ | — | — |
| Tool compatibility (Figma, Tokens Studio) | — | — | ✓ | — |
| Code-defined tokens | — | — | — | ✓ |
| No build step required | ✓ | ✓ | ✓ | ✓ |
SCSS comments inside :root | — | ✓ | — | — |
.scss context or uses SCSS-style comments. JSON is ideal when tokens come from a design tool export. JS/TS is useful for component library packages that expose token constants.