Skip to content

[3.1] Any colour token at any opacity, plus a brand-to-accent gradient - #568

Merged
lorant-one merged 5 commits into
previewfrom
feat/any-token-any-opacity
Nov 23, 2026
Merged

lorant-one merged 5 commits into
previewfrom
feat/any-token-any-opacity

Conversation

@lorant-one

Copy link
Copy Markdown
Member

Requested by Lorant · project thread

Prototype. Don't merge without Lorant's go.

Why

3.0 has three alpha steps per tone (weak, medium, strong = 15, 30, 50%) and nothing between them. On the ATOR site, glows needed 12, 16 and 22%, so hand-made --my-colour variables got hard-coded, which is exactly what the agent rules forbid.

What

Props. Colour props take an opacity after a slash: background, solid, border and the border sides, on Flex/Row/Column/Grid and everything built on them.

<Column background="brand/12" border="brand/22" />   // the tone itself
<Row solid="accent-strong/40" />                      // the prop's own token at 40%
<Grid background="neutral-alpha-strong/50" />         // an alpha step, scaled again
<Column background="gradient" />                      // brand → accent
<Column background="gradient/16" />                   // …at 16%
  • "brand/N" reads the new --brand-alpha token, the colour the alpha scale is drawn from, so brand/15 is exactly brand-alpha-weak, and the named steps become presets on one continuous scale.
  • "brand-strong/N" reads the same variable the class would (--brand-background-strong on background, --brand-border-strong on border).
  • The server writes color-mix(in srgb, <token> N%, transparent) inline, the way the alpha tokens are made. There's no class per step, the box stays a server component, and it follows theme, scheme and StyleScope. A user's style still wins.
  • Typed as ColorAlpha = \${ColorScheme | Colors}/${number}``, so autocomplete on the base still works.

Free colour props. cssColor (StyleScope, Background, charts, gauges) reads the same forms: brand/12, brand-strong/40, --my-hue/50. A raw rgb(0 0 0 / 50%) keeps its own slash.

Tokens (foundations).

  • --{tone}-alpha for all seven tones, in both themes.
  • --accent-color-strong|medium|weak, mirroring --brand-color-* (the hue, whatever data-solid says).
  • --gradient-brand-accent (135°) for stylesheets, and a .gradient-background utility whose angle follows --gradient-angle on the element.

CSS pattern (artwork and keyframes): color-mix(in srgb, var(--brand-alpha) 16%, transparent). Now documented in basics/color.

Options considered

  • More named steps (alpha-subtle, alpha-faint…): still a fixed set, so the next design needs another, and the token surface grows.
  • A separate backgroundOpacity prop: it pairs badly with border/solid (one opacity prop per colour prop), and opacity already means element opacity.
  • A class per step (.brand-background-12): 7 tones × 3 roles × 101 steps, and the CSS bloats.
  • An @property --alpha inherited var on every class: it touches every generated class, and an inheriting var leaks into children.
  • Chosen: slash syntax plus inline color-mix. It's one mental model (Tailwind users already read /12) with no new classes, and it works in breakpoint borders and free colour props too.

Not in this prototype

  • onBackground/onSolid text at an opacity. Text colour should stay on contrast-checked tokens, so I left it out on purpose.
  • background/solid inside breakpoint objects. They had no breakpoint support before either. Breakpoint borders do take it.

Checks

  • tsc --noEmit in core: 0 errors.
  • Core vitest: all pass, including a new color-alpha.test.tsx with 11 tests.
  • Foundations: 68 pass. The CSS API snapshots were updated for the 11 new tokens and the 1 new class, and once-ui.tokens.json was re-exported.
  • The validate-ai-code check finds no issues in the demo page.
  • Screenshots in dark and light are in the project thread (/mnt/project-files/3.1/alpha-tokens/). The demo is at apps/dev /alpha-tokens, and docs are in basics/color, "Any colour at any opacity".

The AI spec and catalog are not regenerated here, per the release-cycle rule.


Generated by Claude Code

…adient

Colour props take an opacity after a slash: background="brand/12",
border="accent-strong/40", solid="brand-strong/60". A bare tone is its
alpha colour (new --{tone}-alpha token; brand/15 equals brand-alpha-weak),
a tone-weight is the prop's own token. The server writes a color-mix()
inline, so there is no class per step and the box stays a server component.

background="gradient" (and gradient/16) draws brand to accent, turned by
--gradient-angle. New tokens: --{tone}-alpha, --accent-color-*,
--gradient-brand-accent. cssColor (StyleScope, Background, charts) reads
the same forms. Docs section in basics/color, demo at /alpha-tokens.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016gNJtzxGSCQk1M71BeZLgj
@lorant-one lorant-one changed the title [3.1 candidate] Any colour token at any opacity, plus a brand-to-accent gradient [3.1] Any colour token at any opacity, plus a brand-to-accent gradient Nov 21, 2026
@lorant-one
lorant-one marked this pull request as ready for review November 21, 2026 12:20
…ved to internal/alpha)

fx holds a word-for-word copy of core's cssColor; it now imports the
opacity helper from a sibling internal/alpha.ts, copied to fx with its own
parity test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016gNJtzxGSCQk1M71BeZLgj
@lorant-one
lorant-one merged commit 067a99d into preview Nov 23, 2026
9 checks passed
lorant-one added a commit that referenced this pull request Nov 23, 2026
#568 widened colour props (ColorAlpha, gradient) and #579 added
WorkspaceSwitcher without regenerating ai/ and bundle-size.json, so the
harness agents read described the old API. The catalog cap moves to 32,500
for 3.1's new pieces.


Claude-Session: https://claude.ai/code/session_016gNJtx8NozwfTMFAJUwVuh

Co-authored-by: Claude <[email protected]>
@github-actions github-actions Bot mentioned this pull request Nov 24, 2026
27 tasks done
@lorant-one lorant-one added the approved label Nov 24, 2026 — with Claude
@lorant-one
lorant-one deleted the feat/any-token-any-opacity branch November 29, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants