Frontend style system boundaries
Scope: web/ (Umi Max + React + antd 6). This page defines which styling mechanism owns which concern, so new code has a single decision rule instead of four competing ones. Reviewed 2026-11-10 against the actual tree.
The four layers and what each owns
| Layer | Entry point | Owns | Current usage |
|---|---|---|---|
| antd theme token | web/src/utils/antdThemeConfig.ts (runtime truth) + web/config/config.ts antd.theme.token (build-time fallback) | Look and feel of antd components: color palette, radius, spacing semantics | Active; two presets × light/dark |
antd-style createStyles | web/src/** component files | Component-local styles for non-antd building blocks | Active; 6 production files (+1 test) |
web/src/global.less | Global stylesheet | App shell (body/topbar/sider/cards), theme CSS variables | Active; two presets × light/dark, four variable sets |
| Tailwind CSS 4 | package.json devDependency + umi @tailwindcss/postcss generator | Nothing | Installed but not activated |
antd theme token — the only way to restyle antd components
- The runtime source of truth is
web/src/utils/antdThemeConfig.ts: fourThemeConfigobjects (blue/inkpink × light/dark). Consumers areapp.tsx(the umi antd plugin's runtime export, so the first frame is correct) and<ThemeSync>(web/src/components/ThemeSync/, pushes on toggle). web/config/config.tsonly pins build-time fallbacks (borderRadius: 8,borderRadiusLG: 12,colorPrimary: '#1677ff'). It must not grow a parallel palette; full token sets live inantdThemeConfig.ts.- Contrast-driven token choices carry their WCAG rationale inline (for example
colorTextSecondarylifted from antd default#8c8c8cat 3.3:1 to#595959at ≥7:1). Keep that pattern: every intentional deviation from an antd default gets a comment with the measured ratio. - Do not override antd component internals from
global.lessor ad-hoc CSS. If a component looks wrong, fix the token (component-scopedcomponents:block inantdThemeConfig.tswhen it is one component, globaltoken:when it is systemic).
antd-style createStyles — component-local styles
- Use
createStyles(({ token, css }) => ...)fromantd-stylefor styles that belong to one non-antd component (list stand-ins, dropdown wrappers, page-local layout). - Colors must derive from
token(token.colorBgContainer,token.colorText, ...), not from hard-coded hex values, so preset and dark-mode switches propagate automatically. Cross-reference the theme variables fromglobal.lessonly when the color genuinely belongs to the app shell palette rather than the antd token set. - Precedent:
web/src/components/SimpleList/index.tsx(the antd 6 List replacement),web/src/components/HeaderDropdown/,web/src/components/RightContent/AvatarDropdown.tsx.
global.less — app shell and theme variables
- Owns: the shell surfaces (body, topbar, sider, cards) and the four CSS variable sets (
--app-*,--brand-*) keyed by<html data-preset="blue|inkpink">×<html data-theme="light|dark">.web/src/utils/themeModewrites the attributes;<ThemeSync>keeps antd tokens in step. - Consumers: ~32
.tsxfiles readvar(--app-*)/var(--brand-*)inline, concentrated in PageStudio / CompositeEditor canvas code where values must react to the preset switch without a React re-render. - Twin-source contract:
global.lessvariable blocks andutils/antdThemeConfig.tstoken blocks describe the same two presets and are maintained in parallel on purpose (antd tokens cannot express the shell variables; CSS variables cannot feed antd algorithms). Any palette change must update both sides plusdocs/.vitepress/theme/custom.css(docs site), in the same PR. - Do not add per-component overrides here. It is a shell/variable sheet, not a component stylesheet.
Tailwind 4 — installed but not activated
tailwindcss 4.x is a devDependency and umi's tailwind generator is wired (@tailwindcss/postcss appears in the umi app data), but no stylesheet imports tailwindcss, no @tailwind/@theme directive exists, and no utility classes are used in web/src. Effective status: dormant.
Decision rule until this changes:
- Do not start using utility classes opportunistically. Activating Tailwind is a deliberate architecture decision because its preflight reset and its utility vocabulary overlap with both the antd token system and the
global.lessvariable system. - If a future need justifies activation, first extend this page with: the activation point (which stylesheet imports it), preflight handling (disable or scope it so antd baseline styles are untouched), and which of the four layers it replaces or complements. Then land the activation in the same PR as the documentation update.
Decision rule for new styles
- Is it how an antd component should look? →
antdThemeConfig.tstoken (orcomponents:block for a single component). - Is it a style belonging to one custom component? →
createStyleswithtoken-derived colors. - Is it shell surface or a theme-dependent shared color? →
global.lessvariable (and check whether the same color needs an antd token twin). - Everything else (truly one-off, positional): inline style is tolerated, but read colors from
var(--app-*)/var(--brand-*)ortoken, never hard-coded hex.
Guardrails in the tree
web/tests/antd6Deprecations.test.tsbans deprecated antd components (for example antdList) at the component-import level; replacement stand-ins live underweb/src/components/.- There is no stylelint. Layer boundaries are enforced by review against this page, not by a lint rule. If violations accumulate, the follow-up is a stylelint rule set, not silent tolerance.
Related
- UI audit and contrast baseline:
docs/review/2026-10-31-ui-audit-impeccable.md - antd 6 deprecation ledger:
docs/BUGS.md(BUG-015, BUG-022) - Versioning/dependency policy that governs the antd/antd-style/tailwind package versions: Version and dependency policy
