Use oklab
instead of oklch
for color-mix(…)
and gradients
#15201
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #15184, #14955
There's a strange bug in Safari < 18 where mixing a color with
transparent
or with a gray tone, the resulting color looks as if it's been interpolated through a red-ish color.Here's the same blue to transparent gradient in Safari 17 using OKLAB and OKLCH for comparison:
In other browsers, both of these examples look identical.
This bug also shows up when using an opacity modifier right now because we use
in oklch
in ourcolor-mix(…)
calls:This PR updates all of the affected places in Tailwind to use
in oklab
instead ofin oklch
which then renders everything as expected in all browsers.The big unfortunate change here is changing the default behavior of gradient utilities like
bg-linear-to-r
to usein oklab
instead ofin oklch
. This means you get muddier gradients by default when creating a gradient between two regular colors (no transparent or gray), like how they looked in v3:This feels worth it though to avoid people getting bitten by this Safari bug without realizing it, and people can always opt in to using OKLCH with classes like
bg-linear-to-r/oklch
. The nice thing about making this opt-in is that no one will opt-in to this when using transparent or gray because it won't make things look any different/better, and the only places where it does make things look better do work as expected in Safari anyways.