Skip to content

fix(docs): resolve color token values so swatches render in docs pages#759

Open
maarkN wants to merge 1 commit into
frappe:mainfrom
maarkN:fix/docs-color-token-swatches
Open

fix(docs): resolve color token values so swatches render in docs pages#759
maarkN wants to merge 1 commit into
frappe:mainfrom
maarkN:fix/docs-color-token-swatches

Conversation

@maarkN

@maarkN maarkN commented Jun 5, 2026

Copy link
Copy Markdown

Fixes #760

Problem

On the docs Design System pages (yarn docs:dev → Background Color, Border Color,
Text Design › Text Color), all color swatches render transparent/empty — the colors
don't show up.

Root cause

The semantic color tokens generated in tailwind/colorPalette.js resolve to Tailwind
strings containing the internal <alpha-value> placeholder, e.g.:

color-mix(in srgb, var(--surface-gray-2, #F3F3F3) calc(<alpha-value> * 100%), transparent)

That placeholder is only substituted by Tailwind when generating utility classes.
docs/content/docs/design-system/[token].paths.ts was passing this raw value to the
token components, which use it as an inline style (backgroundColor / color /
borderColor) — invalid CSS, so the swatches rendered transparent.

Fix

Added a small resolver in [token].paths.ts that extracts the theme-aware
var(--token, fallback) portion of the value and applied it in the three color
getters (getBgColors, getTextColors, getBorderColors). Since the CSS variables
are defined on :root / [data-theme="dark"] by the theme plugin, the swatches also
follow dark mode correctly.

Before / After

06-before-after-background-color

Dark mode (swatches follow the theme):
05-after-background-color-dark

Also fixes Border Color and Text Design › Text Color, which used the same data:

03-after-border-color 04-after-text-design

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Color swatches render empty on Design System docs pages

1 participant