Design Token System

Atomic CSS lets you define project design tokens in a .atomic.json file. When tokens are configured, they appear at the top of autocomplete with a mark.

Key Idea: Define tokens in .atomic.json to boost them in autocomplete, and optionally enable strict mode to enforce your team's design system.

Overview

The Design Token System centrally manages your project's colors, spacing, font sizes, border radii, and font weights, and prioritizes them in autocomplete suggestions.

1Define design tokens in .atomic.json
2Token values appear at the top of autocomplete with a mark
3With strict: true, non-token values trigger warnings
Without tokens, everything works 100% the same as before (backward compatible)

Autocomplete Priority

Values defined in tokens appear at the top of autocomplete with a mark.

100% Backward Compatible

If no tokens are configured, the extension works exactly as before. No impact on existing projects.

Strict Mode

Set strict: true to warn on non-token values and suggest the nearest token via Quick Fix.

Token Configuration (.atomic.json)

Create a .atomic.json file at your project root and define tokens.

.atomic.json
{
    "cssDirectoryPath": "/assets/css/common/",
    "tokens": {
        "colors": {
            "primary": "6366F1",
            "secondary": "A855F7",
            "danger": "EF4444",
            "success": "22C55E",
            "warning": "F59E0B",
            "text": "333333",
            "text-light": "999999",
            "bg": "FFFFFF",
            "bg-dark": "18181B",
            "border": "DDDDDD"
        },
        "spacing": [4, 8, 12, 16, 20, 24, 32, 40, 48, 64],
        "fontSize": [12, 14, 16, 18, 20, 24, 32, 40],
        "borderRadius": [4, 8, 12, 16, 50],
        "fontWeight": [400, 500, 600, 700]
    },
    "strict": false
}

Note: cssDirectoryPath sets the CSS variable scan path, while tokens and strict are design token settings. All fields are optional.

Token Types

Each token type maps to specific CSS property prefixes.

colors — Color Palette

Applied to c, bg, bc prefixes. Define HEX 6-digit values as key-value pairs. When typing c, autocomplete shows c6366F1 ★ primary at the top.

"colors": {
    "primary": "6366F1",
    "secondary": "A855F7",
    "danger": "EF4444",
    "success": "22C55E",
    "warning": "F59E0B",
    "text": "333333",
    "text-light": "999999",
    "bg": "FFFFFF",
    "bg-dark": "18181B",
    "border": "DDDDDD"
}
InputAutocomplete DisplayCSS
cc6366F1 ★ primarycolor: #6366F1
ccEF4444 ★ dangercolor: #EF4444
bgbgFFFFFF ★ bgbackground-color: #FFFFFF
bgbg18181B ★ bg-darkbackground-color: #18181B
bcbcDDDDDD ★ borderborder-color: #DDDDDD

spacing — Spacing Values (px)

Applied to gap, m, p, mt, mb, ml, mr, pt, pb, pl, pr prefixes. Values under 20px use px, 20px and above are auto-converted to rem.

"spacing": [4, 8, 12, 16, 20, 24, 32, 40, 48, 64]
Token ValueGenerated ClassApplied Prefixes
4gap4px, p4px, m4px ...gap, m, p, mt, mb, ml, mr, pt, pb, pl, pr
8gap8px, p8px, m8px ...gap, m, p, mt, mb, ml, mr, pt, pb, pl, pr
12gap12px, p12px, m12px ...gap, m, p, mt, mb, ml, mr, pt, pb, pl, pr
16gap16px, p16px, m16px ...gap, m, p, mt, mb, ml, mr, pt, pb, pl, pr
20gap2rem, p2rem, m2rem ...gap, m, p, mt, mb, ml, mr, pt, pb, pl, pr
24gap2-4rem, p2-4rem, m2-4rem ...gap, m, p, mt, mb, ml, mr, pt, pb, pl, pr
32gap3-2rem, p3-2rem, m3-2rem ...gap, m, p, mt, mb, ml, mr, pt, pb, pl, pr
64gap6-4rem, p6-4rem, m6-4rem ...gap, m, p, mt, mb, ml, mr, pt, pb, pl, pr

fontSize — Font Size (px)

Applied to the fs prefix. Same px→rem conversion rule as spacing.

"fontSize": [12, 14, 16, 18, 20, 24, 32, 40]
Token ValueGenerated Class
12fs12px
14fs14px
16fs16px
18fs18px
20fs2rem
24fs2-4rem
32fs3-2rem
40fs4rem

borderRadius — Border Radius (px)

Applied to the br prefix.

"borderRadius": [4, 8, 12, 16, 50]
Token ValueGenerated Class
4br4px
8br8px
12br12px
16br16px
50br5rem

fontWeight — Font Weight

Applied to the fw prefix. Classes are generated with raw numeric values (no units).

"fontWeight": [400, 500, 600, 700]
Token ValueGenerated Class
400fw400
500fw500
600fw600
700fw700

Strict Mode

The strict option lets you set token usage to free mode or team mode.

strict: false (default) — Free Mode

Tokens are boosted in autocomplete, but any value can still be used freely.

Tokens appear at the top of autocomplete with a mark
Non-token values can still be used freely
No warnings

strict: true — Team Mode

Non-token values get a warning underline, and Quick Fix suggests the nearest token value.

!Non-token values show a warning underline
!Quick Fix suggests the nearest token value
!Colors use RGB distance; spacing/fonts use the nearest allowed value

Strict Mode Warning Examples

Using values not in the token list triggers a warning with a Quick Fix suggestion.

ViolationWarning MessageQuick Fix
bgABCDEFColor not in project palettebg6366F1 (primary)
gap13pxAllowed spacing: 4, 8, 12, 16, 20, 24, 32, 40, 48, 64gap12px / gap16px
fs15pxAllowed font sizes: 12, 14, 16, 18, 20, 24, 32, 40fs14px / fs16px

CSS Variable Synergy

Combine token names with CSS variables for consistent design. bg--primary uses var(--primary), while bg6366F1 uses #6366F1 — both reference the same design color through variables or direct values.

<!-- CSS variable approach -->
<div class="bg--primary c--text">
  Uses var(--primary) and var(--text)
</div>

<!-- Direct token value approach -->
<div class="bg6366F1 c333333">
  Uses #6366F1 and #333333 directly
</div>

<!-- Both reference the same design token "primary: 6366F1" -->
<!-- bg--primary = background-color: var(--primary) -->
<!-- bg6366F1   = background-color: #6366F1          -->

CSS Variable Approach

bg--primaryvar(--primary)
Variable values can be changed at runtime, ideal for dark mode toggling.

Direct Value Approach

bg6366F1#6366F1
No variable definition needed. Tokens ensure it appears at the top of autocomplete.

CSS Variable Autocomplete

Your project's CSS/SCSS files are automatically scanned for :root variables, which then appear in autocomplete.

1CSS/SCSS files in the cssDirectoryPath are scanned
2Typing bg-- shows real project variable names in autocomplete
3The variable's original value and source file are also displayed
/* Your project CSS/SCSS file */
:root {
  --primary: #6366f1;
  --secondary: #a855f7;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 32px;
  --radius: 8px;
}

/* Type "bg--" in HTML class → autocomplete shows: */
/* bg--primary       → background-color: var(--primary)     #6366f1  (from style.css) */
/* bg--secondary     → background-color: var(--secondary)   #a855f7  (from style.css) */

Tip: Set cssDirectoryPath to scan CSS/SCSS files in that path for :root variables. If not set, the extension searches default paths relative to the project root.

Tips & Cautions

Tokens Are Optional

If the tokens field is not set, Atomic CSS works exactly the same as before. You can adopt tokens gradually.

Automatic px to rem Conversion

Values under 20px use px units, 20px and above auto-convert to rem. (Based on 1rem = 10px)

Strict Mode for Teams

Set strict: true to enforce the same design tokens across your entire team. Commit .atomic.json to git and share it.

CSS Variable Scan Path

Set cssDirectoryPath to scan CSS/SCSS files in that directory for :root variables and use them in autocomplete.