Skip to content

Theme: Carry near-gray seed tints into generated neutral tokens - #86052

Merged
ciampo merged 6 commits into
WordPress:trunkfrom
yaman-694:fix/theme-near-gray-seed-tint
Nov 13, 2026
Merged

ciampo merged 6 commits into
WordPress:trunkfrom
yaman-694:fix/theme-near-gray-seed-tint

Conversation

@yaman-694

@yaman-694 yaman-694 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Closes #86038. Related contrast work is in #86614.

What?

Modern and Light now carry their background tint into the neutral surfaces and strokes generated by ThemeProvider. Fresh, Midnight, and Coffee also change: their neutrals stay closer to the original background color. Blue, Ectoplasm, Ocean, and Sunrise produce the same background ramps as trunk.

Why?

The old taper treated a color as gray when its OKLCH chroma fell below 0.005. Modern (#222524) and Light (#eaeeed) both fall below that cutoff, so their base surface kept its tint while neighboring surfaces turned gray. Just above the cutoff, the taper could amplify a faint tint.

How?

Tapered background steps now use a ceiling that grows with the seed's chroma. A faint tint stays close to the seed, and richer colors can use the existing taper. Accent ramps keep their existing behavior, including when a custom primary color is near gray.

Chroma ceiling and measured color changes

For seed chroma C, the ceiling is C × (1 + (C / 0.02)²). The ramp applies it before rounding to 8-bit RGB. A very faint tint can still round to gray.

Admin scheme Background seed Strong neutral surface on trunk Strong neutral surface in this PR
Modern #222524 #2a2a2a #282b2a
Light #eaeeed #f6f6f6 #f3f8f6
Fresh #25292b #263034 #2a2f31
Midnight #3d4042 #3d464c #424547
Coffee #5b534d #655448 #61554c

Testing Instructions

  1. In this branch's Storybook, open Design System → Theme → Theme Provider → Color Scales → Sample Combinations.
  2. Find Modern admin dark and Light. Expand Color values and check surface3 in the background ramp against the table above. Compare the neutral surfaces and strokes with the screenshots.
  3. Check Fresh, Midnight, and Coffee for the subtler tint. Use Ocean as a comparison: its background surface3 is #3f5c64 on both revisions.
  4. In the Default story, set the primary to #222524 and the background to #fcfcfc. Expand Color values. In the primary ramp, surface2 is #f8f8f8 and surface6 is #d1d1d1, matching trunk.

Testing Instructions for Keyboard

Tab to Color values and press Enter to expand the table. Each swatch has a text value for comparison.

Screenshots or screencast

Each overview shows the input seed beside six neutral surface and stroke tokens rendered by ThemeProvider. Modern and Light gain a faint tint. Fresh, Midnight, and Coffee move closer to their seeds.

Modern and Light background seeds and six neutral tokens, with trunk and PR hex values

Fresh, Midnight, and Coffee background seeds and six neutral tokens, with trunk and PR hex values

The full ramps below compare all 22 generated steps, with the names used in Storybook's Color values table. The input seed appears above each ramp. For Coffee, the seed is #5b534d, while both revisions generate #59514b for the base surface (surface2).

Full background ramps for Modern and Light

Modern background seed #222524. Seventeen of 22 steps change, including surface3 from #2a2a2a to #282b2a.

Light background seed #eaeeed. Eighteen of 22 steps change, including surface3 from #f6f6f6 to #f3f8f6.

Full background ramps for Fresh, Midnight, and Coffee

Fresh background seed #25292b. Eleven of 22 steps change, including surface3 from #263034 to #2a2f31.

Midnight background seed #3d4042. Nine of 22 steps change, including surface3 from #3d464c to #424547.

Coffee background seed #5b534d. Nine of 22 steps change, including surface3 from #655448 to #61554c.

Near-white background, Ocean, and a near-gray primary

With the near-white seed #fcfcfd, some steps pick up a faint tint while surface3 still rounds to white. All 22 steps match trunk for the Ocean background and for #222524 used as a primary color on #fcfcfc.

Near-white background seed #fcfcfd. Seventeen steps change. Surface3 rounds to white on both revisions.

Ocean background seed #5f787f. All 22 generated steps match trunk.

Near-gray primary seed #222524 on background #fcfcfc. All 22 generated accent steps match trunk.

Use of AI Tools

Codex assisted with the rebase, code review, accent-ramp fix, regression tests, screenshots, and this description.

@github-actions github-actions Bot added the [Package] Theme /packages/theme label Oct 30, 2026
@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground

👋 Welcome

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @yaman-694! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: yaman-694 <yamanzyan@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

@github-actions github-actions Bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Oct 30, 2026
@yaman-694
yaman-694 marked this pull request as ready for review November 2, 2026 08:18
@yaman-694
yaman-694 requested a review from a team as a code owner November 2, 2026 08:18
@ciampo ciampo added the [Type] Enhancement A suggestion for improvement. label Nov 2, 2026
@ciampo

ciampo commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Hello, and thank you for working on this!

This looks like a viable solution to improve on the abrupt near-gray cutoff. It also fits with the perceptual-scale work in #82294 and the foreground experiments in #82037, which retain the neutral chroma taper.

Could you add before-and-after comparisons (screenshots) for a few example color ramps? Especially the ones you mentioned (modern, light)? Maybe you could use this storybook example.

Separately, can you also add a Theme changelog entry? Thank you 🙏

@yaman-694

Copy link
Copy Markdown
Contributor Author

Hi @ciampo added the screenshot and Changelog

@ciampo

ciampo commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Thank you, the screenshots definitely help with getting a sense for the changes. In general, I think that the PR is currently adding too much of the seed's chroma into the remp.

Light's generated neutral surfaces reach about five times the seed's chroma, which makes the ramp look noticeably greener than the seed. Could we carry its hue while keeping the neutral ramp closer to the seed's chroma? If this issue is specific to neutral scales, the brand and other accent ramps should retain their existing treatment.

The experimental diff below reproduces the subtler seed-bounded result for neutral ramps while leaving the accent algorithm unchanged.

Proposed experiment and diff

This adds an internal option to bound chroma by the seed's chroma after applying the existing taper. It enables that option only for the background ramp. The contrast solver and gamut mapping stay in place.

Against 977f298254d52e366c04969c57b90dfdc220cc7f, it reproduces the prototype for six sampled background seeds, which pass the existing background-ramp contrast checks. All 66 sampled accent/background combinations retain their previous values. This is an exploratory diff; the unit tests and snapshots still need to be updated and run before merging. In particular, an extremely faint tint can round to gray in 8-bit RGB, so the current assertion that every generated step has nonzero chroma needs revisiting.

diff --git a/packages/theme/src/color-ramps/lib/taper-chroma.ts b/packages/theme/src/color-ramps/lib/taper-chroma.ts
--- a/packages/theme/src/color-ramps/lib/taper-chroma.ts
+++ b/packages/theme/src/color-ramps/lib/taper-chroma.ts
@@ -16,6 +16,7 @@
 	radiusDark?: number; // distance in L where kDark is reached (default 0.20)
 	kLight?: number; // floor multiplier near lighter side (default 0.85)
 	kDark?: number; // floor multiplier near darker side (default 0.85)
+	limitToSeedChroma?: boolean; // keep neutral chroma at or below the tapered seed chroma
 	// Near-gray handling: cap C at C_seed * nearGrayChromaRatio * (1 + (C_seed / nearGrayChroma)²)
 	nearGrayChromaRatio?: number; // cap multiplier for a near-gray seed (default 4)
 	nearGrayChroma?: number; // seed C above which the cap quickly stops binding (default 0.005)
@@ -105,7 +106,10 @@
 			kLight,
 			kDark,
 		} );
-		const cPlanned = Math.min( cWithCarry * t, cCap );
+		const cPlanned = Math.min(
+			cWithCarry * t,
+			options.limitToSeedChroma ? cSeed * t : cCap
+		);
 
 		// Downward-only clamp (preserve L & H)
 		const lOut = clamp01( lTarget );
diff --git a/packages/theme/src/color-ramps/lib/ramp-configs.ts b/packages/theme/src/color-ramps/lib/ramp-configs.ts
--- a/packages/theme/src/color-ramps/lib/ramp-configs.ts
+++ b/packages/theme/src/color-ramps/lib/ramp-configs.ts
@@ -50,7 +50,7 @@
 	taperChromaOptions: FG_TAPER_CHROMA,
 };
 
-export const BG_RAMP_CONFIG: RampConfig = {
+const BASE_RAMP_CONFIG: RampConfig = {
 	// Surface
 	surface1: {
 		contrast: {
@@ -231,37 +231,53 @@
 	},
 };
 
+// Bound neutral ramps independently of the accent ramp's chroma treatment.
+export const BG_RAMP_CONFIG = Object.fromEntries(
+	Object.entries( BASE_RAMP_CONFIG ).map( ( [ stepName, step ] ) => [
+		stepName,
+		step.taperChromaOptions
+			? {
+					...step,
+					taperChromaOptions: {
+						...step.taperChromaOptions,
+						limitToSeedChroma: true,
+					},
+				}
+			: step,
+	] )
+) as RampConfig;
+
 // BG_RAMP: seed => surface2 => {bgFill, surface3 => all other tokens}
 // ACCENT_RAMP: seed => bgFill1 => surface2 => surface3 => all other tokens
 export const ACCENT_RAMP_CONFIG: RampConfig = {
-	...BG_RAMP_CONFIG,
+	...BASE_RAMP_CONFIG,
 	surface1: {
-		...BG_RAMP_CONFIG.surface1,
+		...BASE_RAMP_CONFIG.surface1,
 		taperChromaOptions: ACCENT_SURFACE_TAPER_CHROMA,
 	},
 	surface2: {
 		contrast: {
 			reference: 'bgFill1',
 			followDirection: 'opposite',
-			target: BG_RAMP_CONFIG.bgFill1.contrast.target,
+			target: BASE_RAMP_CONFIG.bgFill1.contrast.target,
 			ignoreWhenAdjustingSeed: true,
 		},
 		taperChromaOptions: ACCENT_SURFACE_TAPER_CHROMA,
 	},
 	surface3: {
-		...BG_RAMP_CONFIG.surface3,
+		...BASE_RAMP_CONFIG.surface3,
 		taperChromaOptions: ACCENT_SURFACE_TAPER_CHROMA,
 	},
 	surface4: {
-		...BG_RAMP_CONFIG.surface4,
+		...BASE_RAMP_CONFIG.surface4,
 		taperChromaOptions: ACCENT_SURFACE_TAPER_CHROMA,
 	},
 	surface5: {
-		...BG_RAMP_CONFIG.surface5,
+		...BASE_RAMP_CONFIG.surface5,
 		taperChromaOptions: ACCENT_SURFACE_TAPER_CHROMA,
 	},
 	surface6: {
-		...BG_RAMP_CONFIG.surface6,
+		...BASE_RAMP_CONFIG.surface6,
 		taperChromaOptions: ACCENT_SURFACE_TAPER_CHROMA,
 	},
 	bgFill1: {
@@ -272,36 +288,36 @@
 		},
 	},
 	stroke1: {
-		...BG_RAMP_CONFIG.stroke1,
+		...BASE_RAMP_CONFIG.stroke1,
 	},
 	stroke2: {
-		...BG_RAMP_CONFIG.stroke2,
+		...BASE_RAMP_CONFIG.stroke2,
 	},
 	stroke3: {
-		...BG_RAMP_CONFIG.stroke3,
+		...BASE_RAMP_CONFIG.stroke3,
 		sameAsIfPossible: 'fgSurface3',
 		taperChromaOptions: undefined,
 	},
 	stroke4: {
-		...BG_RAMP_CONFIG.stroke4,
+		...BASE_RAMP_CONFIG.stroke4,
 		taperChromaOptions: undefined,
 	},
 	// fgSurface: do not de-saturate
 	fgSurface1: {
-		...BG_RAMP_CONFIG.fgSurface1,
+		...BASE_RAMP_CONFIG.fgSurface1,
 		taperChromaOptions: undefined,
 	},
 	fgSurface2: {
-		...BG_RAMP_CONFIG.fgSurface2,
+		...BASE_RAMP_CONFIG.fgSurface2,
 		taperChromaOptions: undefined,
 	},
 	fgSurface3: {
-		...BG_RAMP_CONFIG.fgSurface3,
+		...BASE_RAMP_CONFIG.fgSurface3,
 		taperChromaOptions: undefined,
 		sameAsIfPossible: 'bgFill1',
 	},
 	fgSurface4: {
-		...BG_RAMP_CONFIG.fgSurface4,
-		taperChromaOptions: undefined,
-	},
-};
+		...BASE_RAMP_CONFIG.fgSurface4,
+		taperChromaOptions: undefined,
+	},
+};

WDYT ?

@yaman-694

Copy link
Copy Markdown
Contributor Author

Thanks @ciampo, I tried the diff locally and it matches what you described. The near-gray neutral steps now stay within about 1.0-1.2x of the seed chroma (Light was at ~5x before), the accent ramps are unchanged, and there are no new contrast warnings.

One thing I noticed: since limitToSeedChroma applies to every background ramp, it also lowers the chroma of saturated background seeds, so all of the background ramp snapshots at lightness 10-90 change (for example, at L50 / H0, surface6 goes from #9a5859 to #8e5e5e). Is that intended? If so, I'll update the snapshots and note it in the changelog entry. If not, I can scope the bound to near-gray seeds only.

I'll also rework the near-gray test as you suggested: assert chroma ≤ seed chroma instead of nonzero chroma, and check hue only on steps whose chroma survives 8-bit rounding.

Image

@ciampo

ciampo commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Yeah, that broader desaturation isn't great.

I decided to try an approach; I've merged trunk and replaced the global seed limit with a "softer ceiling" (quadratic) for background ramps, so near-gray seeds keep their subtle tint while richer backgrounds retain their previous treatment. Accent ramps keep their existing treatment too.

I kept the saturated-surface changes and the missing 3:1 constraints separate in the stacked draft #86614, since those can change the generated primary color quite visibly.

The soft quadratic ceiling is the third row. It allows chroma up to C_seed × (1 + (C_seed / 0.02)²) on tapered background steps. That stays close to the seed for faint tints and releases the bound as chroma increases. All rows use the merged contrast fix #86189, so the comparison isolates the chroma approaches.

Image Image Image Image

What do you think?

@yaman-694

Copy link
Copy Markdown
Contributor Author

Thanks @ciampo, I like this approach a lot. I pulled your commit and ran the color-ramps tests (all 135 pass). I also compared all nine admin scheme backgrounds against trunk:

  • Modern / Light now carry their tint at roughly 1.0-1.3x the seed chroma, which looks much closer to the seed than my original cap.
  • Ocean, Blue, Ectoplasm, Sunrise are identical to trunk, and so is #996666.
  • Fresh, Midnight and Coffee also change, though. Their seeds sit just above the old 0.005 cutoff, so trunk already tinted them at about 2-3x the seed chroma. The new ceiling brings them down to roughly 1.2-1.5x:
Scheme Seed C surface3 trunk surface3 now
Fresh #25292b 0.0068 #263034 (C 0.0155) #2a2f31 (C 0.0079)
Midnight #3d4042 0.0053 #3d464c (C 0.0156) #424547 (C 0.0052)
Coffee #5b534d 0.0143 #655448 (C 0.0295) #61554c (C 0.0213)

I think this is actually the consistent outcome: those schemes had the same over-tinting that made Light look too green, and now every near-gray scheme is treated the same way, with no jump around the old threshold. Leaving them as they were would mean a steep transition somewhere between C 0.005 and 0.007, which is the kind of discontinuity this PR set out to remove. Just flagging it since it goes beyond Modern and Light. Does that sound right to you (and maybe @jameskoster from the design side)?

If so, I'll update the PR description: the before/after tables, the list of affected schemes, and the screenshots for the new ceiling. Happy to also look at #86614 once this lands.

yaman-694 and others added 6 commits November 12, 2026 19:40
A background seed with an OKLCH chroma just under the 0.005 achromatic
threshold, such as the "Modern" admin scheme's #222524, kept its tint on
the base surface while every tapered step came out pure gray, so the two
mixed on the same screen. Seeds either side of the threshold also gave
visibly different ramps.

Fade the carried chroma linearly to zero below the threshold instead of
cutting it off, so a slight tint carries into every step in proportion.
Seeds at or above the threshold and gray seeds are unchanged.
Fading the carried chroma below the old threshold still let the
seed-relative normalization amplify imperceptible tints near the
lightness extremes: #f6f7f9 (C 0.0029) produced strokes at C 0.032.

Cap the carried chroma at a multiple of the seed's own chroma instead.
The allowance grows quadratically with the seed chroma, so it only binds
for near-gray seeds, keeps every ramp continuous and fades to gray as the
seed does. This makes the achromatic threshold unnecessary, so remove it
together with the unused hueFallback option.
@ciampo
ciampo force-pushed the fix/theme-near-gray-seed-tint branch from 3323459 to 39b519e Compare November 12, 2026 18:44

@ciampo ciampo 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.

@yaman-694 I pushed a small and updated the PR description.

LGTM 🚀

Although let's see if anyone else from @WordPress/gutenberg-components wants to share any additional feedback.

@ciampo

ciampo commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

I'll go ahead and merge, happy to address any additional feedback in follow-ups.

@ciampo
ciampo merged commit f19cd5b into WordPress:trunk Nov 13, 2026
111 of 113 checks passed
@github-actions github-actions Bot added this to the Gutenberg 24.5 milestone Nov 13, 2026
Vedant-Gandhi pushed a commit to Vedant-Gandhi/gutenberg that referenced this pull request Nov 30, 2026
…Press#86052)

* Theme: Carry near-gray seed tints into generated neutral tokens

A background seed with an OKLCH chroma just under the 0.005 achromatic
threshold, such as the "Modern" admin scheme's #222524, kept its tint on
the base surface while every tapered step came out pure gray, so the two
mixed on the same screen. Seeds either side of the threshold also gave
visibly different ramps.

Fade the carried chroma linearly to zero below the threshold instead of
cutting it off, so a slight tint carries into every step in proportion.
Seeds at or above the threshold and gray seeds are unchanged.

* Theme: Cap near-gray tints instead of fading them

Fading the carried chroma below the old threshold still let the
seed-relative normalization amplify imperceptible tints near the
lightness extremes: #f6f7f9 (C 0.0029) produced strokes at C 0.032.

Cap the carried chroma at a multiple of the seed's own chroma instead.
The allowance grows quadratically with the seed chroma, so it only binds
for near-gray seeds, keeps every ramp continuous and fades to gray as the
seed does. This makes the achromatic threshold unnecessary, so remove it
together with the unused hueFallback option.

* Theme: Add changelog entry for near-gray seed tint fix

* ThemeProvider: Ensure near-gray background seeds carry their tint into generated surfaces and strokes

* Theme: Soften the near-gray chroma ceiling

* Theme: Preserve accent ramps for near-gray primary colors

---------

Co-authored-by: yaman-694 <yamanzyan@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Package] Theme /packages/theme [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Theme: near-neutral background seeds give a tinted surface but grey generated tokens

2 participants