Repository navigation
spec(theme-tokens): spacing tokens are rem and follow the root font size - #7373
Conversation
…me-tokens INV9, DEC-1) Core spacing defaults are rem; a theme overriding steps uses rem for the same reason, a px pin is that theme's documented exception, and author-written values in custom themes are never converted. Spacing has no base-unit derivation, so the only generator surface is the CLI's theme templates, which copy a source theme's steps verbatim.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec d415fd3 |
There was a problem hiding this comment.
This PR adds a new rule to a current spec record (INV9, DEC-1 and the INV9 verification row in architecture:theme-tokens), so approval needs a maintainer to adopt that rule with the points below in view. Independent of that decision, please fix these:
- DEC-1 says only the CLI theme templates generate spacing values, but the docsite playground theme editor derives a
pxspacing ramp from a base step and exports it asdefineThemesource. - INV9 says
useTheme().token()andresolveThemeToken()return theremstring, but under a theme with apxpin (matcha's--spacing-4is24px) they returnpx, so describe the value by unit instead. - The INV9 row's failure signal, “a scaffolded theme emitting
pxsteps”, flags the documentedpxexceptions INV9 allows, and today it also fails on the ejected matcha and y2k themes that DEC-1 accepts. - “the same pixel value as before” and “until they move to
rem” in DEC-1 describe the change rather than the system, which the R1 rubric result missed.
[Automated review]
| Non-CSS consumers (`useTheme().token()`, `resolveThemeToken()`, | ||
| `tokenDefaults`) return the `rem` string; code that needs pixels resolves it | ||
| against the root font size instead of parsing a number. |
There was a problem hiding this comment.
resolveThemeToken() and useTheme().token() apply theme.tokens over tokenDefaults, so under a theme with a px pin (matcha's --spacing-4 is 24px) they return px, not rem. Suggested wording: they return the resolved string as written — rem for the core defaults, or the unit a theme sets — so code that needs pixels converts by unit instead of parsing a number.
|
|
||
| Spacing tokens are `rem`. A reader who raises the browser's root font size gets | ||
| proportionally larger gaps and padding, so text does not tighten inside boxes | ||
| that stayed in pixels; at the default 16px root every step is the same pixel |
There was a problem hiding this comment.
“the same pixel value as before” describes the change rather than the system (rubric R1). Suggested: “at the default 16px root, --spacing-N computes to N × 4px”. “until they move to rem” a few lines down has the same problem.
| value as before. Spacing has no base-unit derivation: `defineTheme` takes spacing only as | ||
| per-step token overrides, so nothing generates spacing values except the CLI's | ||
| theme templates, which copy a first-party theme's steps verbatim; a scaffolded | ||
| theme therefore emits `rem` steps once its source theme does. Theme authors keep |
There was a problem hiding this comment.
The docsite playground theme editor also generates spacing values: buildSpacingScale in apps/docsite/src/app/playground/themeEditor/helpers.ts writes every step as round(base × step)px, and the playground exports the result as defineTheme source. Either narrow this sentence to Core and the CLI or name that generator.
| | INV5 | Domain-token exports and theme-generation tests | Domain names disappear from validation or require importing unused domain implementation | | ||
| | INV6 | `packages/core/src/theme/tokens.test.ts` | JavaScript resolution disagrees with defaults, mode selection, references, or supported color expressions | | ||
| | INV8 | `defineTheme.test.ts`, template checks, and token-doc generation | A local name enters portable helpers/docs or can conflict with a portable declaration | | ||
| | INV9 | `tokens.test.ts` rem assertions, a real-Chromium root-font-size spec, and the theme-template check | A core spacing default in `px`, or a scaffolded theme emitting `px` steps | |
There was a problem hiding this comment.
This failure signal fires on what INV9 allows: a theme's documented px pin is an exception, and astryx theme eject scaffolds bundled copies of matcha and y2k that still emit px. Suggested: “… or a scaffolded theme emitting a px step its source theme does not document as an exception”, with evidence that reads the bundled themes; scripts/check-theme-template.test.mjs asserts nothing about spacing units.
…cribe helper values by unit, and stay in the present tense
|
/approve-spec a8e023d |
There was a problem hiding this comment.
The new spacing rule has the record owner's approval on the current commit, but two wording issues in architecture:theme-tokens should be fixed before it lands, and the fixing commit will need a fresh /approve-spec.
- INV9 requires every spacing generator, including the CLI theme templates that copy first-party themes verbatim, to emit
remwhile also allowing a theme's documentedpxexception, and the verification row fails only a step “that no theme pinned”, so please state one rule in all three places, count the visual-gate probe generator in DEC-1, and link the record that owns thedefineThemeinput for DEC-1's premise. - The INV9 verification row cites the theme-template check, which reads only the annotated theme template and asserts nothing about spacing units, so please name checks that read the bundled theme copies and the playground's generated ramp.
[Automated review]
| Anything that generates spacing steps — the CLI's theme templates and the | ||
| docsite playground's theme editor — emits `rem`. Non-CSS consumers |
There was a problem hiding this comment.
This sentence has no exception, but lines 107–108 let a theme keep a documented px step, the CLI theme templates are byte copies of the first-party theme sources, and the INV9 row fails only a px step “that no theme pinned”. Please state one rule in all three places, for example: “a generated or copied spacing step is rem unless it reproduces a theme's documented px exception”.
| `defineTheme` has no spacing base unit: it takes spacing only as per-step token | ||
| overrides. Two surfaces generate spacing steps and both emit `rem`: the CLI's | ||
| theme templates, which copy a first-party theme's steps verbatim, and the | ||
| docsite playground's theme editor, which derives a ramp from a base step and | ||
| exports it as `defineTheme` source. Theme authors keep control: a theme may pin |
There was a problem hiding this comment.
Two points here: the visual-gate probe generator also writes a spacing step (packages/themes/probe/src/probeConfig.ts is generated by .github/scripts/visual-gate/generate-probe-theme.mjs and sets '--spacing-4': '17px'), so “Two surfaces” undercounts; and the defineTheme premise is a fact this record says it does not own (line 119), so link architecture:theme-authoring-contract for it instead of restating it.
| | INV5 | Domain-token exports and theme-generation tests | Domain names disappear from validation or require importing unused domain implementation | | ||
| | INV6 | `packages/core/src/theme/tokens.test.ts` | JavaScript resolution disagrees with defaults, mode selection, references, or supported color expressions | | ||
| | INV8 | `defineTheme.test.ts`, template checks, and token-doc generation | A local name enters portable helpers/docs or can conflict with a portable declaration | | ||
| | INV9 | `tokens.test.ts` rem assertions, a real-Chromium root-font-size spec, and the theme-template check | A core spacing default in `px`, or a generator (CLI template, playground editor) emitting a `px` step that no theme pinned | |
There was a problem hiding this comment.
scripts/check-theme-template.test.mjs checks the annotated theme.template.ts (fields, token families and names, theming targets, doc topics, SYNC comments) and the Neutral palette files; it reads no bundled theme's spacing values and nothing from the playground editor, so it cannot detect the generator half of this failure signal. Please name evidence that reads the bundled theme copies' spacing values and the playground ramp instead.
PR Analysis Report
|
…ce; the verification row names the checks that read units
|
/approve-spec 4742aa5 |
There was a problem hiding this comment.
No remaining issues: INV9, DEC-1 and the INV9 verification row in architecture:theme-tokens now state one documented-exception rule for every spacing surface, DEC-1 links architecture:theme-authoring-contract for the defineTheme input, and the row names checks that read units for the core defaults, theme overrides, CLI copies and playground ramp. The record owner's approval is on this exact commit, so nothing more is needed here; the checks the row names arrive with the two implementation pull requests.
[Automated review]
Exact decision needed
Whether the core
--spacing-*scale isrem(so gaps and padding follow the reader's root font size, as the type scale does) or stays fixedpx, and what that means for themes that override spacing steps and for custom themes.Existing authority searched
architecture:theme-tokens(current): names, roles, defaults, helpers, projections — no unit rule for spacing.design:iconography(draft): icon sizes useremso they scale with the root font size — the precedent for this decision.packages/core/src/theme/tokens.stylex.ts(spacing defaults inpx),defineTheme(spacing only as per-step token overrides; no base-unit derivation), the first-party themes (matcha and y2k pin steps inpx; the others inherit core), and the two generators: the CLI theme templates (verbatim copies of a source theme's steps) and the docsite playground theme editor (derives a ramp from a base step and exportsdefineThemesource).Decision
Spacing tokens are
rem(--spacing-N= N × 0.25rem; unchanged pixel values at the default root). A theme that overrides steps usesremfor the same reason; apxpin is that theme's documented exception; author-written values in custom themes are honoured as written. Non-CSS helpers return theremstring. Decided by the owner on 2026-10-12 (architecture:theme-tokensDEC-1), with the accepted costs recorded: fixed-width table columns at very large roots, matcha/y2k until they move torem, and code that parses a spacing token as a pixel number.Delta
docs/architecture/theme-tokens.md: INV9 (routed under thetokenstrigger), a verification row, DEC-1.Implementation: the open spacing-tokens pull request changes the core scale and the playground editor's generated ramp to
rem; moving matcha's and y2k's pinned steps (package and CLI template copies) and the annotated theme template's'12px'spacing example toremis its own small change behind this record.Writing rubric results
Search terms:
spacing rem,root font size,--spacing,spacingDefaults,rem-basedacrossdocs/, open and closed pull requests. Overlapping work: the open spacing-tokens implementation pull request (code only, no record change) and the merged icon-size precedent.