Design tokens
Tokens are the contract between design and code. They are named for meaning, not for value —
--mrd-text-muted, never --mrd-grey-500.
Naming
--mrd-{category}-{role}-{variant}
--mrd-color-bg page background
--mrd-color-text primary text
--mrd-color-text-muted secondary text
--mrd-accent interactive / selected
--mrd-radius-sm control corners
A token that only exists because one component needed it is not a token — it is a local variable and should stay inside that component.
Colour
| Token | Light | Dark |
|---|---|---|
--mrd-color-bg | #FFFFFF | #101312 |
--mrd-color-surface | #FFFFFF | #161A18 |
--mrd-color-surface-alt | #F7F7F5 | #161A18 |
--mrd-color-line | #E3E6E1 | #272D29 |
--mrd-color-text | #171A18 | #ECEDEA |
--mrd-color-text-soft | #47504A | #B1B7B1 |
--mrd-color-text-muted | #737D76 | #868E88 |
--mrd-accent | #1F6F5C | #6FBFA4 |
--mrd-accent-soft | #EAF4F0 | #16241F |
--mrd-success | #2F7D4F | #5FB884 |
--mrd-warning | #B0741C | #D9A45E |
--mrd-danger | #A8322A | #E0796F |
Typography
| Token | Value |
|---|---|
--mrd-font-sans | system-ui, -apple-system, "Segoe UI", Inter, Arial |
--mrd-font-mono | ui-monospace, SFMono-Regular, Menlo, Consolas |
--mrd-text-xs | 11px / 16px |
--mrd-text-sm | 13px / 20px |
--mrd-text-md | 15px / 26px |
--mrd-text-lg | 16px / 24px |
--mrd-text-xl | 20px / 28px |
--mrd-text-2xl | 24px / 32px |
--mrd-text-3xl | 32px / 40px |
Space, radius, motion
| Token | Value |
|---|---|
--mrd-space-1 … 6 | 4 / 8 / 12 / 16 / 24 / 32 px |
--mrd-radius-sm | 6px |
--mrd-radius-md | 10px |
--mrd-radius-pill | 999px |
--mrd-ease | cubic-bezier(.2, .8, .3, 1) |
--mrd-dur-fast | 120ms |
--mrd-dur-base | 180ms |
Density
Density is a single switch that recalculates spacing and control heights:
[data-density="compact"] {
--mrd-row-h: 32px;
--mrd-control-h: 28px;
--mrd-space-2: 6px;
--mrd-space-4: 12px;
}
Using tokens from JavaScript
Custom properties are readable at runtime, so canvas charts and virtualised lists can stay in sync with the theme without duplicating the palette:
const styles = getComputedStyle(document.documentElement);
const accent = styles.getPropertyValue("--mrd-accent").trim();
chart.update({ lineColor: accent });
Re-read them when the theme changes — a matchMedia("(prefers-color-scheme: dark)")
listener is enough.
Versioning
Token names are API. Renaming one is a breaking change and ships in a major version with a
deprecation period of one minor release, during which both names resolve to the same value.