Skip to documentation
Design system / Sources & standards
Current repository source
ADR-0030-design-token-architecture-for-cxhub-base-theme.md
docs/decisions/ADR-0030-design-token-architecture-for-cxhub-base-theme.md
This view contains the escaped source read during the deployment build. Code and policy text are unchanged. Markdown is shown as source, not rendered as a document. A new deployment refreshes the content.
# ADR-0030: Design token architecture for cxhub base theme
## Status
accepted
## Date
2026-07-06
## Context
The project uses shadcn/ui and Tailwind CSS v4. The existing `src/app/globals.css` declared a minimal set of CSS variables directly, which:
- Did not expose the full shadcn semantic contract (e.g. `--muted`, `--accent`, `--destructive`), causing some existing component classes to resolve incorrectly.
- Mixed primitive values and semantic aliases in one file.
- Provided no extension point for tenant-specific surgical overrides.
- Made it difficult to reason about spacing and type scales because `1rem` defaulted to the browser's `16px` root size.
As the product moves toward multi-tenant white-labeling, we need a token architecture that separates raw values from semantic intent and can be overridden per tenant without rewriting components.
## Decision
- Introduce a `src/theming/` directory that owns all design tokens.
- Split tokens into **primitives** (`--cxh-*`) and **semantics**.
- Primitives live in `src/theming/primitives/` by category: colors, typography, spacing, radii, shadows, motion, layout, z-index.
- Semantics live in `src/theming/semantics/` by category: core (shadcn-compatible), surfaces, text, borders, feedback, focus, states, typography.
- Keep the standard shadcn semantic variables unprefixed (`--background`, `--primary`, `--muted`, etc.) so existing shadcn/base components continue to work.
- Prefix all primitive tokens with `--cxh-` to avoid collisions with shadcn or userland CSS.
- Use `oklch()` for color primitives, matching the existing project style.
- Establish a `1rem = 10px` rem base by setting `html { font-size: 62.5%; }`.
- Use Tailwind v4's spacing multiplier (`--spacing`) so existing utility classes (`p-4`, `px-3`, etc.) keep their pixel values while landing on a 4px grid.
- Override Tailwind v4 font-size and radius theme keys to preserve familiar pixel sizes on the constrained grid.
- Expose standard shadcn color utilities plus a small extended set (`success`, `warning`, `info`, `surface-raised`, `text-link`, etc.) through Tailwind v4's `@theme inline`.
- Preserve the existing `.dark` class strategy for dark mode; only remap semantic tokens inside `.dark`.
- Defer the tenant override mechanism to a follow-up branch. This branch establishes the token structure so tenant overrides can later be added as a single semantic remap layer.
## Consequences
- Token organization is now explicit and extensible.
- Existing shadcn classes (`bg-muted`, `text-muted-foreground`, `hover:bg-accent`, etc.) now resolve correctly.
- Existing layouts and text sizes are preserved despite the `1rem = 10px` change.
- Future tenant themes can override semantic tokens without touching component code.
- Brand colors and feedback colors in this branch are placeholders and must be replaced with approved values before finalizing the cxhub brand.
## Related decisions
- Supersedes the informal token approach in ADR-0010 for the shadcn/Tailwind baseline.
- Tenant override mechanism will be documented in a future ADR once implemented.
All sources and standards