Don't read variables for shadow sizes #13449
Merged
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.
Resolves #13438
In #13177 we changed the way utility values are referenced in utility classes to use variables with fallbacks instead of raw values:
This creates an issue with colored shadows, because colored shadows rely on being able to override the value of a sub-variable that is reference by the actual shadow variable created based on your theme configuration.
Simplified but representative code:
The problem here is that
var(--shadow-sm, ...)
will see that--shadow-sm
is defined on:root
, and use the computed value of that variable from:root
, where--tw-shadow-color
is yet to be defined, so the color falls back toblack
even when using theshadow-blue
utility:This caught me by surprise personally as I expected CSS variables to be evaluated lazily but it seems like they are not. The only solution I've found here is to not reference the
--shadow-sm
variable in the.shadow-sm
class, to make sure the value of--tw-shadow-color
on the current element is respected, rather than looking for the value of--tw-shadow-color
where--shadow-sm
is defined:This is pretty unfortunate because now our box shadow utilities behave subtly differently than every other utility in the framework. I'm hoping we can find some trick to make these variables lazily evaluated, and tweeted about it in case someone else out there has any ideas.
For now though we should merge this to effectively selectively revert #13177 for the affected utilities.