Fix: Set neutral, zinc, and stone color palettes to use 'none' for Hue in OKLCH#19833
Fix: Set neutral, zinc, and stone color palettes to use 'none' for Hue in OKLCH#19833nmurrell07 wants to merge 1 commit intotailwindlabs:mainfrom
Conversation
…e in OKLCH This fixes the Abney Effect and hue-shifting issue when mixing neutral colors with other colors using color-mix() in OKLCH space. Neutral colors should have their Hue component set to 'none' (powerless) to ensure that when mixed with other colors, the hue of the non-neutral color is preserved, resulting in a natural desaturation rather than a hue shift. Fixes tailwindlabs#19830
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe change updates color definitions in the Tailwind CSS compatibility module by modifying the oklch color format for specific color palettes. The zinc and mauve palettes are updated at the '50' color stop, while the neutral palette is updated across multiple stops from '50' through '950'. In each case, zero values for chroma and hue parameters in the oklch format are replaced with the 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip You can customize the tone of the review comments and chat replies.Configure the |
Summary
This PR fixes the Abney Effect and hue-shifting issue when mixing neutral colors with other colors using
color-mix()in OKLCH space.Problem
When mixing a themed green color (e.g.,
green-700) with a neutral color (e.g.,neutral-700) using the CSScolor-mix(in oklch, ...)function, the resulting color unexpectedly shifts toward yellow instead of becoming a desaturated dark green.This happens because Tailwind's default neutral, zinc, and stone palettes define their OKLCH hue as
0(which represents the Red/Magenta axis in OKLCH) instead ofnone. When performing a linear interpolation in a color-mix:green-700(Hue ≈ 150)neutral-700(Hue = 0)Solution
Neutral colors in OKLCH should have their Hue component set to
none(powerless). This ensures that when mixed with other colors, the hue of the non-neutral color is preserved, resulting in a natural desaturation rather than a hue shift to yellow.Changes
neutralpalette: Changed all colors fromoklch(X% 0 0)tooklch(X% none none)zincpalette: Changed all colors fromoklch(X% 0 0)tooklch(X% none none)stonepalette: Changed all colors fromoklch(X% 0 0)tooklch(X% none none)Test Plan
color-mix(in oklch, green-700, neutral-700)now produces a desaturated dark green instead of a yellowish colorFixes #19830