Preserve shadow color when overriding shadow size #14458
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.
This PR changes how shadow color and shadow size utilities interact when used with variants.
Take this HTML:
Currently this shadow would be red by default, but revert to the default semi-transparent black color on hover.
This PR changes this behavior such that the shadow remains red on hover, and only the shadow size changes.
We deliberately didn't do this originally because making things behave this way makes it very difficult to get the default shadow color back once you've changed it. The default color for
shadow-xl
for instance isrgb(0 0 0 / 0.1)
, and the only way to get that color back after changing it is to know that value and explicitly bring it back:To make things more difficult, the default shadow color is not the same across shadow sizes. For
shadow-sm
it'sblack/5
, and forshadow-2xl
it'sblack/25
.In practice though you basically never need to bring back the default shadow color, so I'm reconsidering this trade-off in v4, and think I prefer this new behavior where the color is preserved but you have to bring back the default color if you actually need it.
A simple workaround if you don't know the color is to reset the
--tw-shadow-color
variable like this:This relies on semi-private internals though, so perhaps we can introduce a utility for this, like
shadow-default
orshadow-initial
that just unsets the shadow color.