#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere
Theme system (core/theme/)
Read this before touching colours or theming anywhere in the frontend.
TL;DR rules
- Never write a raw colour (
#hex,rgb(),hsl(), or a named colour likered) in a component, inline style, or stylesheet. Use a token:var(--c-…)— a semantic token (preferred:--c-text,--c-surface,--c-primary, …).var(--p-…)— a palette primitive, only when no semantic token fits.
- The only file allowed to contain literal colours is
primitives.css. If you need a new hue, add it there first, then reference it. - Structural
black/white/transparent(shadows, scrims, overlays) are allowed anywhere. - Colours must adapt to light/dark automatically. If you're reaching for a hardcoded colour "just for dark mode", you're doing it wrong — pick the right
--c-*token. task frontend:lint:colorsenforces rules 1–3 insidecore/theme/(see Linter).
Files
| File | Role |
|---|---|
primitives.css |
The palette. 41 literal colours (--p-*) — one neutral ramp (--p-gray-* light, --p-zinc-* dark) + status hues (blue/green/amber/red). The ONLY place literals live. |
colors.css |
Semantic tokens (--c-*), mapped from primitives per theme. This is what you should reference. |
dimensions.css |
Non-colour tokens: spacing, radius, z-index, type, motion. |
index.css |
Barrel that @imports the above. Imported by ThemeProvider (and Storybook). |
mantineTheme.ts |
Mantine theme object wiring. |
The old compat.css legacy-alias layer has been removed — every component now references --c-* directly. Two legacy colour files still exist outside this folder and are being phased out — prefer --c-* over their tokens, and don't add to them:
core/styles/theme.css (editor --bg-*/--text-* vocab) and core/tokens/tokens.css (SUI --color-* vocab, gradients, code palette).
Semantic tokens (--c-*)
Reference these, not primitives, wherever possible:
- Surfaces (elevation):
--c-bg(canvas) <--c-bg-raised(sidebars/toolbars) <--c-surface(cards/modals) <--c-surface-raised<--c-surface-sunken; plus--c-input-bg,--c-hover,--c-active,--c-overlay. - Text:
--c-text,--c-text-muted,--c-text-subtle,--c-text-on-primary(foreground on a filled primary). - Borders:
--c-border,--c-border-subtle,--c-border-strong. - Accent:
--c-primary,--c-primary-hover,--c-primary-subtle, and--c-accent-fg(see below). - Status:
--c-success,--c-danger.
Theme model
The mode and the accent colour are independent.
preferences.themeis the mode:light|dark|system(System follows the OS). There is no separate "custom" or "midnight" mode any more.- Light and dark each have their own accent:
preferences.lightPrimary/preferences.darkPrimary(both default#3b82f6blue). ThemeProviderresolves the mode to a concretelight/darkbase, picks that side's accent, and always setsdata-app-theme="custom"on<html>. So the custom-tint blocks incolors.cssare the only themed blocks that apply — the chosen accent drives every accent and a subtle app-wide surface tint. With the default blue the tint is near-neutral.- Selection attributes on
<html>:data-theme=light|dark(SUI + the tint blocks),data-mantine-color-scheme=light|dark(Mantine).
Custom-theme contrast guardrails (core/utils/customPrimary.ts)
Because the accent is user-chosen, deriveAccessiblePrimary(pick, base) clamps it and injects three vars on <html>:
--user-primary→--c-primary. Lightness-clamped so it can't collapse into the base (dark floorL ≥ 0.42, light ceilL ≤ 0.6). Used for fills.--user-primary-on→--c-text-on-primary. White by default; flips to black only for genuinely light picks (relative-luminance cutoff0.62, so saturated amber/green/cyan keep white text).--user-accent-fg→--c-accent-fg. The accent tuned as a foreground (text/icon on the app surface): forced light on dark bases (L ≥ 0.62), dark on light (L ≤ 0.45), so accent text never goes dark-on-dark.
Rule of thumb: a filled control's background uses --c-primary with its label on --c-text-on-primary; an accent used as text/icon on a surface (nav selection, links, tool-header text) uses --c-accent-fg. Reference it as var(--c-accent-fg, var(--c-primary)) — the fallback keeps non-custom builds (where --c-accent-fg is unset) on the raw primary.
The FAB / logo mark is a deliberate exception: it's pinned to white (--p-white), not the on-primary flip — a brand mark, not body text.
Linter
One file: scripts/lint/theme-lint.mjs (no baseline). Run via task frontend:lint:colors (part of task frontend:lint).
- Default (blocking): enforces "literals only in
primitives.css; everything else incore/theme/references tokens; no duplicate primitives." Scope is deliberately justcore/theme/— the layer this owns, which is clean. node theme-lint.mjs contrast(taskfrontend:contrast, non-blocking): WCAG contrast report for text-on-surface / on-primary pairs per theme.
App-wide "no hardcoded colours in components" is not enforced yet (there are 260+ legacy sites); that's a separate migration. Don't add new hardcoded colours regardless.
Gotchas
--mantine-*vars are consumed by Mantine at runtime, not via ourvar(). A source scan can't see their use — never delete them as "unused", and set them (not raw colours) when overriding Mantine.--accent-*(categorical hues) are used dynamically via`var(--accent-${hue})`inutils/accentColors.ts. A literal search won't find them — don't treat them as unused.- Tailwind consumes some vars (
--gray-*,--color-*,--background,--border) viaeditor/tailwind.config.jsusingrgb(var(--x)). That file is outside the usual scan roots — check it before removing those. - Specificity: if a token you set in
colors.css(html[data-app-theme="custom"], 0,1,1) isn't winning, a:root:rootor a[data-mantine-color-scheme]-compound block in the legacy files is probably overriding it — set it in the more specific block. - Adding a colour: put the literal in
primitives.css, map it to a--c-*incolors.cssif it's a new semantic role, and reference the--c-*from components. Don't skip straight to a--p-*in a component unless there's genuinely no semantic fit.