Skip to content
OverviewMarkdown

Tokens

Every design value passes through a three-tier token architecture: primitive scales feed semantic role tokens, and semantic tokens feed component contracts. Components never read primitive tokens directly.

Three-tier architecture

LayerTS source → CSS outputExamplesContract
1. Primitivecolor.ts, scales.ts, layout.ts → color.css, scales.css, layout.css--obsidian-1 (hsl(220, 6%, 5%)), --verdigris-9 (hsl(175, 32%, 31%)), --space-4 (1rem / 16px), --radius-md (0.5rem / 8px)8 color scales × 12 steps, 12 spacing steps, 7 radii, 3 border widths, 4 shadows, 10 type steps, 5 durations, 3 easings, 6 z-index steps. Never read directly by components.
2. Semanticsemantic.ts → semantic.css, theme.css--background, --foreground, --primary, --border, --input, --ring, --code-keyword53 role tokens mapped across 4 brand themes (mono, verdigris, brass, porphyry) and 2 modes (dark, light). Bridged to Tailwind utilities via @theme inline.
3. Componentcomponents.ts → components.css--control-height-md (2.5rem / 40px), --focus-ring-width (2px), --card-radius (var(--radius-lg))4 control size contracts (xs, sm, md, lg), focus ring geometry (2px width, 2px offset), and card radius (16px / 1rem).
Control sizeHeight tokenIcon tokenRadius token
xs--control-height-xs: 1.5rem (24px)--control-icon-xs: 1rem (16px)--control-radius-xs: var(--radius-sm) (0.25rem / 4px)
sm--control-height-sm: 2rem (32px)--control-icon-sm: 1rem (16px)--control-radius-sm: var(--radius-sm) (0.25rem / 4px)
md--control-height-md: 2.5rem (40px)--control-icon-md: 1.25rem (20px)--control-radius-md: var(--radius-md) (0.5rem / 8px)
lg--control-height-lg: 3rem (48px)--control-icon-lg: 1.5rem (24px)--control-radius-lg: var(--radius-md) (0.5rem / 8px)

TypeScript modules under packages/monoplinth/src/tokens/ are the single source of truth. Running npm run tokens:build emits deterministic CSS custom properties that theme.css bridges into Tailwind CSS v4.

Primitive scale inventory

ScaleUnitDefined steps from TS
Spacing (--space-*)16px = 1rem (step = px / 4)--space-1: 0.25rem (4px) · --space-2: 0.5rem (8px) · --space-3: 0.75rem (12px) · --space-4: 1rem (16px) · --space-6: 1.5rem (24px) · --space-8: 2rem (32px) · --space-10: 2.5rem (40px) · --space-12: 3rem (48px) · --space-16: 4rem (64px) · --space-20: 5rem (80px) · --space-24: 6rem (96px) · --space-32: 8rem (128px)
Sizingpx / rem16px (1rem) · 24px (1.5rem) · 32px (2rem) · 40px (2.5rem) · 48px (3rem)
Radius (--radius-*)rem--radius-none: 0rem (0px) · --radius-xs: 0.125rem (2px) · --radius-sm: 0.25rem (4px) · --radius-md: 0.5rem (8px) · --radius-lg: 1rem (16px) · --radius-xl: 1.5rem (24px) · --radius-full: 624.9375rem (9999px)
Border width (--border-width-*)px--border-width-1: 1px · --border-width-2: 2px · --border-width-4: 4px
Fonts (--font-*)family stack--font-display: Sora, system-ui, -apple-system, sans-serif · --font-sans: Sora, system-ui, -apple-system, sans-serif · --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace
Motion duration (--duration-*)ms (φ-based)--duration-100: 100ms · --duration-162: 162ms · --duration-262: 262ms · --duration-424: 424ms · --duration-686: 686ms
Motion easing (--ease-*)cubic-bezier--ease-standard: cubic-bezier(0.2, 0, 0, 1) · --ease-enter: cubic-bezier(0, 0, 0.2, 1) · --ease-exit: cubic-bezier(0.4, 0, 1, 1)
Z-index (--z-*)integer layer--z-base: 0 · --z-sticky: 10 · --z-dropdown: 20 · --z-overlay: 30 · --z-modal: 40 · --z-toast: 50

Default Tailwind CSS scales are reset with --*: initial in theme.css. Only the defined Monoplinth token steps resolve to utility classes.

Semantic color mapping

Semantic tokenTailwind classMono (default)VerdigrisBrassPorphyry
--backgroundbg-background--obsidian-1--obsidian-1--obsidian-1--obsidian-1
--foregroundtext-foreground--obsidian-12--obsidian-12--obsidian-12--obsidian-12
--cardbg-card--obsidian-3--obsidian-3--obsidian-3--obsidian-3
--card-foregroundtext-card-foreground--obsidian-12--obsidian-12--obsidian-12--obsidian-12
--popoverbg-popover--obsidian-3--obsidian-3--obsidian-3--obsidian-3
--popover-foregroundtext-popover-foreground--obsidian-12--obsidian-12--obsidian-12--obsidian-12
--primarybg-primary--obsidian-9--verdigris-9--brass-9--porphyry-9
--primary-hoverbg-primary-hover--obsidian-10--verdigris-10--brass-10--porphyry-10
--primary-activebg-primary-active--obsidian-9--verdigris-9--brass-9--porphyry-9
--primary-foregroundtext-primary-foreground--obsidian-foreground--verdigris-foreground--brass-foreground--porphyry-foreground
--secondarybg-secondary--obsidian-3--obsidian-3--obsidian-3--obsidian-3
--secondary-hoverbg-secondary-hover--obsidian-4--obsidian-4--obsidian-4--obsidian-4
--secondary-activebg-secondary-active--obsidian-5--obsidian-5--obsidian-5--obsidian-5
--secondary-foregroundtext-secondary-foreground--obsidian-12--obsidian-12--obsidian-12--obsidian-12
--mutedbg-muted--obsidian-2--obsidian-2--obsidian-2--obsidian-2
--muted-foregroundtext-muted-foreground--obsidian-11--obsidian-11--obsidian-11--obsidian-11
--accentbg-accent--obsidian-4--obsidian-4--obsidian-4--obsidian-4
--accent-foregroundtext-accent-foreground--obsidian-12--obsidian-12--obsidian-12--obsidian-12
--borderborder-border--obsidian-7--obsidian-7--obsidian-7--obsidian-7
--inputborder-input--obsidian-8--obsidian-8--obsidian-8--obsidian-8
--ringring-ring--obsidian-8--verdigris-8--brass-8--porphyry-8
--destructivebg-destructive--red-9--red-9--red-9--red-9
--destructive-hoverbg-destructive-hover--red-10--red-10--red-10--red-10
--destructive-activebg-destructive-active--red-9--red-9--red-9--red-9
--destructive-foregroundtext-destructive-foreground--red-foreground--red-foreground--red-foreground--red-foreground
--destructive-textbg-destructive-text--red-11--red-11--red-11--red-11
--destructive-subtlebg-destructive-subtle--red-3--red-3--red-3--red-3
--destructive-borderbg-destructive-border--red-6--red-6--red-6--red-6
--disabledbg-disabled--obsidian-3--obsidian-3--obsidian-3--obsidian-3
--disabled-foregroundtext-disabled-foreground--obsidian-8--obsidian-8--obsidian-8--obsidian-8
--infobg-info--blue-9--blue-9--blue-9--blue-9
--info-foregroundtext-info-foreground--blue-foreground--blue-foreground--blue-foreground--blue-foreground
--info-subtlebg-info-subtle--blue-3--blue-3--blue-3--blue-3
--info-borderbg-info-border--blue-6--blue-6--blue-6--blue-6
--info-textbg-info-text--blue-11--blue-11--blue-11--blue-11
--warningbg-warning--orange-9--orange-9--orange-9--orange-9
--warning-foregroundtext-warning-foreground--orange-foreground--orange-foreground--orange-foreground--orange-foreground
--warning-subtlebg-warning-subtle--orange-3--orange-3--orange-3--orange-3
--warning-borderbg-warning-border--orange-6--orange-6--orange-6--orange-6
--warning-textbg-warning-text--orange-11--orange-11--orange-11--orange-11
--successbg-success--green-9--green-9--green-9--green-9
--success-foregroundtext-success-foreground--green-foreground--green-foreground--green-foreground--green-foreground
--success-subtlebg-success-subtle--green-3--green-3--green-3--green-3
--success-borderbg-success-border--green-6--green-6--green-6--green-6
--success-textbg-success-text--green-11--green-11--green-11--green-11
--code-backgroundbg-code-background--obsidian-3--obsidian-3--obsidian-3--obsidian-3
--code-foregroundtext-code-foreground--obsidian-12--obsidian-12--obsidian-12--obsidian-12
--code-keywordtext-code-keyword--obsidian-12--verdigris-12--brass-12--porphyry-12
--code-commenttext-code-comment--obsidian-11--obsidian-11--obsidian-11--obsidian-11
--code-stringtext-code-string--obsidian-11--verdigris-11--brass-11--porphyry-11
--code-numbertext-code-number--obsidian-11--verdigris-11--brass-11--porphyry-11
--code-functiontext-code-function--obsidian-12--verdigris-12--brass-12--porphyry-12
--code-punctuationtext-code-punctuation--obsidian-11--obsidian-11--obsidian-11--obsidian-11

Each semantic token references a primitive color variable (var(--<scale>-<step>)). Switching modes updates the primitive values under .light, while switching brand themes updates only the brand-driven semantic slots under [data-theme].

Usage

Reference semantic and component tokens through Tailwind CSS v4 utilities or CSS custom properties:

<button
  type="button"
  className="inline-flex items-center justify-center rounded-md border border-input bg-primary px-4 font-sans text-body font-medium text-primary-foreground transition-colors duration-162 ease-standard"
  style={{ height: "var(--control-height-md)" }}
>
  Confirm action
</button>
.control-md {
  height: var(--control-height-md);
  padding-inline: var(--space-4);
  border-radius: var(--control-radius-md);
  background-color: var(--primary);
  color: var(--primary-foreground);
  transition: background-color var(--duration-162) var(--ease-standard);
}

.control-md:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

Do and don't

Do: Consume semantic and component tiers
Bind component styles to semantic tokens (bg-card, text-foreground, border-border, ring-ring) and component tokens (--control-height-md, --card-radius).
Don't: Read primitive color steps in components
Do not reference --obsidian-3, --verdigris-9, or raw hsl() strings inside component stylesheets; only docs swatch demos read primitive color tokens.

Accessibility

CategoryTS sourceOutput unit and tokensAccessibility rule
Fluid and scalable dimensionsscales.ts, components.ts, layout.tsrem (16px root base, px / 16)Scales spacing, control heights, and typography with browser zoom
Crisp structural hairlinesscales.ts--border-width-1 (1px), --border-width-2 (2px), --border-width-4 (4px)Keeps borders sharp in px at every zoom level
Focus ring geometrycomponents.ts--focus-ring-width (2px), --focus-ring-offset (2px)Maintains a visible outline on :focus-visible

Scalable layout and typography dimensions convert to rem so interfaces respect browser zoom and user font-size preferences. Structural hairlines and focus rings stay in px, and every semantic foreground pair is verified against WCAG 2.2 AA contrast thresholds.

Rationale

Separating primitive scales from semantic roles allows a single component stylesheet to support dark mode, light mode, and four brand themes without conditional class branches. Generating CSS from typed TypeScript modules prevents drift between runtime calculations, contrast audits, and compiled stylesheets.