Skip to content

spec(theme-tokens): name colour tokens by one grammar - #8103

Merged
cixzhang merged 2 commits into
mainfrom
spec/color-token-grammar
Oct 24, 2026
Merged

cixzhang merged 2 commits into
mainfrom
spec/color-token-grammar

Conversation

@cixzhang

Copy link
Copy Markdown
Contributor

Colour token names follow one grammar, so a theme author or component author can predict a token's name from its job, and a new role can't invent a new naming style.

Exact decision needed

How portable colour tokens are named. The vocabulary grew a consistent practice (--color-text-accent, --color-accent-muted, --color-on-accent, --color-icon-green) that no record states, so new roles keep proposing names outside it (foreground, a status group, -text suffixes).

Existing authority searched

  • architecture:theme-tokens INV1–INV9: INV3 says names describe semantic roles but not how names are formed. No current record owns colour naming.
  • packages/core/src/theme/tokens.stylex.ts (colorDefaults), domainTokens/ (--color-data-*, --color-syntax-*), tailwind-theme.css, and the v0.0.6/v0.0.8 rename codemods: every current colour name fits the five shapes below.
  • Open work: the status-colour roles proposal uses these names and is stacked on this record.

Decision

architecture:theme-tokens INV10. Every portable colour token takes one of five shapes:

  1. --color-<property>-<role>. The property is text, icon, background or border. The role is an emphasis, an intent, a surface, or a hue.
  2. --color-<intent>: the intent's own colour.
  3. A variant suffix: -muted (pale), -emphasized (strong), -hover/-pressed, or -inverted.
  4. --color-on-<fill>: content on a fill. on-<intent> serves the intent's bare and -emphasized fills; a -muted fill pairs with on-<intent>-muted.
  5. Domain layers: --color-data-* and --color-syntax-*.

Six role-less utility names keep their names. New names add no group segment, no other property word, and no property suffix. Tailwind keys may alias a token but never add a CSS variable.

Rejected alternatives

  • A status group or foreground property word (--color-status-foreground-success): this is the only colour name that would put a group before the property, and it gives text a second property word.
  • A -text suffix (--color-success-text): it puts the property last, which contradicts every existing --color-text-* token.

Claim scope and non-goals

The grammar governs names only. It does not decide which roles exist, their values, or theme-local (--astryx-theme-*) names. Existing names are unchanged.

Evidence and implementation relationship

tokens.test.ts adds a name check over colorDefaults and domainTokenDefaults. Every current colour token passes it, and names outside the grammar are rejected.

Writing rubric results

  • R1 narration: none; INV10 states the shapes in the present tense.
  • R2 research in the record: none.
  • R3 evidence naming a change: none; the verification row cites the name check.
  • R4 rejected alternatives over one line or outside a decision: none in the record; the two alternatives above stay in this description.
  • R5 pull request or issue references remaining: none.
  • R6 ruled open questions still listing options: none.

Scope

  • This PR contains specification records only. (It also adds the INV10 name check to tokens.test.ts as the invariant's verification; there is no runtime change and no Changeset.)
  • It records observable behavior and preserves equivalent internal implementations.
  • Any named internal mechanism is intentionally public, names its dependent caller/system, and explains why an equivalent implementation would not satisfy the contract.
  • Verification states the evidence layer and failure signal without prescribing CI job/workflow topology.
  • It records one intentional durable decision, not a rescue for a separable tagalong.
  • The canonical knowledge owner, affected current claims, and overlapping open work are named; any ownership collision is resolved or called out for human decision.
  • Adjacent API, visual, accessibility, composition, and implementation facts remain outside scope unless this exact decision depends on them.
  • Public text and artifacts contain no internal Meta context.

Validation

  • pnpm check:knowledge
  • Prettier
  • git diff --check
  • vitest run packages/core/src/theme/tokens.test.ts (29 passed)

Colour token names take five shapes: property then role, the intent's
own colour, a variant suffix, on- content on a fill, and domain layers.
A name check over the colour and domain defaults verifies it.
@vercel

vercel Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Oct 24, 2026 12:27pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 24, 2026
@astracat-bot

astracat-bot Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🔄 In progress (for maintainers only) Oct 24, 2026, 12:20 PM UTC

@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Oct 24, 2026
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.9KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

46 of 494 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Selector Indicator Space Bottom Sheet Narrow End RTL neutral light 753,933
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,072
Chat Full AI Chat probe light 230,823
Chat Full AI Chat probe dark 229,805
RichTextEditor Markdown parity: side by side probe dark 94,866
RichTextEditor Markdown parity: side by side probe light 89,762
Collapsible Dividers probe dark 66,445
Collapsible Dividers probe light 66,445
Chat Default neutral dark 36,304
Chat Default neutral light 35,767
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,406
Chat With Attachments probe dark 11,232
ProgressBar With Target Mark probe dark 7,895
ProgressBar With Target Mark probe light 7,895
Markdown Default neutral dark 7,573
Markdown Default neutral light 7,566

and 26 more.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

INV10's naming grammar is a new invariant in the current architecture:theme-tokens record, so approval waits on an engineering owner's decision: an engineering owner records it by commenting /approve-spec <full head SHA> on this pull request (the author may do so as an engineering owner), or asks for changes. That decision should settle whether INV10 admits the info intent and --color-on-<intent>-muted names that no token has today, and how it relates to #7657, which adds a different INV10 to the same record using the --color-status-foreground-* names this grammar rejects. Independently, please make INV10's scope exact before that decision, since a new commit resets an approval:

  • Say that the rule covers portable --color-* names other than the listed role-less utility names, and give the verification row's failure signal the same exception; as written, "every name takes one of five shapes" contradicts the eight utility names INV10 keeps.

[Automated review]

Comment thread docs/architecture/theme-tokens.md Outdated
Comment on lines +117 to +118
- **INV10 — Colour token names follow one grammar.** Every portable colour
token name takes one of five shapes:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This says every portable colour token name takes one of the five shapes, but lines 136-138 keep eight current names that take none, and the INV10 failure signal at line 244 reads the same way; only the test's utilityNames set states the exception. It also leaves "colour token" undefined (--focus-outline-color has a colour default and takes no shape). Suggested wording: "Every portable --color-* token name, other than the role-less utility names below, takes one of five shapes:", with a failure signal of "A colour token name fits none of the five shapes and is not a listed utility name".

The grammar governs Astryx's own colour vocabulary: Core and domain
defaults and what first-party themes set. Product, application, theme
author, and other design-system variables are outside it.
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec b37c87c

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Oct 24, 2026
@cixzhang
cixzhang merged commit 443b803 into main Oct 24, 2026
67 checks passed
@github-actions
github-actions Bot deleted the spec/color-token-grammar branch October 25, 2026 06:20

This branch was successfully deployed

1 active deployment
Preview — b37c87c5 Deployed Oct 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant