Skip to content

Commit 6d8dd82

Browse files
Fix shadow-inherit, inset-shadow-inherit, drop-shadow-inherit, and text-shadow-inherit (#17647)
Fixes #17643. This PR completely removes the `color-mix()` function for `shadow-inherit`. This does mean intensity and alpha channel support has been removed when using `shadow-inherit`[^1]. With intensity modifiers in #17398, all colors are wrapped in `color-mix()`. However, it seems `inherit` does not work as a value in `color-mix()` in Firefox or Chrome (don't have a means to test Safari). [^1]: While writing this, I noticed other color utilities allow alpha channel modifier syntax for `inherit` - do we want to look at removing those too? --------- Co-authored-by: Philipp Spiess <[email protected]>
1 parent c0af1e2 commit 6d8dd82

File tree

3 files changed

+33
-18
lines changed

3 files changed

+33
-18
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- Ensure the `color-mix(…)` polyfill creates fallbacks for theme variables that reference other theme variables ([#17562](https://github.com/tailwindlabs/tailwindcss/pull/17562))
1414
- Fix brace expansion in `@source inline('z-{10..0}')` with range going down ([#17591](https://github.com/tailwindlabs/tailwindcss/pull/17591))
1515
- Ensure container query variant names can contain hyphens ([#17628](https://github.com/tailwindlabs/tailwindcss/pull/17628))
16+
- Ensure `shadow-inherit`, `inset-shadow-inherit`, `drop-shadow-inherit`, and `text-shadow-inherit` inherits the shadow color ([#17647](https://github.com/tailwindlabs/tailwindcss/pull/17647))
1617
- Ensure compatibility with array tuples used in `fontSize` JS theme keys ([#17630](https://github.com/tailwindlabs/tailwindcss/pull/17630))
1718
- Upgrade: Convert `fontSize` array tuple syntax to CSS theme variables ([#17630](https://github.com/tailwindlabs/tailwindcss/pull/17630))
1819

packages/tailwindcss/src/utilities.test.ts

+12-18
Original file line numberDiff line numberDiff line change
@@ -20943,6 +20943,8 @@ test('filter', async () => {
2094320943
'drop-shadow-[0_0_red]',
2094420944
'drop-shadow-red-500',
2094520945
'drop-shadow-red-500/50',
20946+
'drop-shadow-none',
20947+
'drop-shadow-inherit',
2094620948
'saturate-0',
2094720949
'saturate-[1.75]',
2094820950
'saturate-[var(--value)]',
@@ -21046,6 +21048,16 @@ test('filter', async () => {
2104621048
filter: var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, );
2104721049
}
2104821050

21051+
.drop-shadow-none {
21052+
--tw-drop-shadow: ;
21053+
filter: var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, );
21054+
}
21055+
21056+
.drop-shadow-inherit {
21057+
--tw-drop-shadow-color: inherit;
21058+
--tw-drop-shadow: var(--tw-drop-shadow-size);
21059+
}
21060+
2104921061
.drop-shadow-red-500 {
2105021062
--tw-drop-shadow-color: #ef4444;
2105121063
--tw-drop-shadow: var(--tw-drop-shadow-size);
@@ -23568,12 +23580,6 @@ test('text-shadow', async () => {
2356823580
--tw-text-shadow-color: inherit;
2356923581
}
2357023582

23571-
@supports (color: color-mix(in lab, red, red)) {
23572-
.text-shadow-inherit {
23573-
--tw-text-shadow-color: color-mix(in oklab, inherit var(--tw-text-shadow-alpha), transparent);
23574-
}
23575-
}
23576-
2357723583
.text-shadow-none {
2357823584
text-shadow: none;
2357923585
}
@@ -23968,12 +23974,6 @@ test('shadow', async () => {
2396823974
--tw-shadow-color: inherit;
2396923975
}
2397023976

23971-
@supports (color: color-mix(in lab, red, red)) {
23972-
.shadow-inherit {
23973-
--tw-shadow-color: color-mix(in oklab, inherit var(--tw-shadow-alpha), transparent);
23974-
}
23975-
}
23976-
2397723977
.shadow-red-500 {
2397823978
--tw-shadow-color: #ef4444;
2397923979
}
@@ -24447,12 +24447,6 @@ test('inset-shadow', async () => {
2444724447
--tw-inset-shadow-color: inherit;
2444824448
}
2444924449

24450-
@supports (color: color-mix(in lab, red, red)) {
24451-
.inset-shadow-inherit {
24452-
--tw-inset-shadow-color: color-mix(in oklab, inherit var(--tw-inset-shadow-alpha), transparent);
24453-
}
24454-
}
24455-
2445624450
.inset-shadow-red-500 {
2445724451
--tw-inset-shadow-color: #ef4444;
2445824452
}

packages/tailwindcss/src/utilities.ts

+20
Original file line numberDiff line numberDiff line change
@@ -4399,6 +4399,14 @@ export function createUtilities(theme: Theme) {
43994399
{
44004400
let value = resolveThemeColor(candidate, theme, ['--drop-shadow-color', '--color'])
44014401
if (value) {
4402+
if (value === 'inherit') {
4403+
return [
4404+
filterProperties(),
4405+
decl('--tw-drop-shadow-color', 'inherit'),
4406+
decl('--tw-drop-shadow', `var(--tw-drop-shadow-size)`),
4407+
]
4408+
}
4409+
44024410
return [
44034411
filterProperties(),
44044412
decl('--tw-drop-shadow-color', withAlpha(value, 'var(--tw-drop-shadow-alpha)')),
@@ -5127,6 +5135,10 @@ export function createUtilities(theme: Theme) {
51275135
case 'none':
51285136
if (candidate.modifier) return
51295137
return [textShadowProperties(), decl('text-shadow', 'none')]
5138+
5139+
case 'inherit':
5140+
if (candidate.modifier) return
5141+
return [textShadowProperties(), decl('--tw-text-shadow-color', 'inherit')]
51305142
}
51315143

51325144
// Shadow size
@@ -5275,6 +5287,10 @@ export function createUtilities(theme: Theme) {
52755287
decl('--tw-shadow', nullShadow),
52765288
decl('box-shadow', cssBoxShadowValue),
52775289
]
5290+
5291+
case 'inherit':
5292+
if (candidate.modifier) return
5293+
return [boxShadowProperties(), decl('--tw-shadow-color', 'inherit')]
52785294
}
52795295

52805296
// Shadow size
@@ -5397,6 +5413,10 @@ export function createUtilities(theme: Theme) {
53975413
decl('--tw-inset-shadow', nullShadow),
53985414
decl('box-shadow', cssBoxShadowValue),
53995415
]
5416+
5417+
case 'inherit':
5418+
if (candidate.modifier) return
5419+
return [boxShadowProperties(), decl('--tw-inset-shadow-color', 'inherit')]
54005420
}
54015421

54025422
// Shadow size

0 commit comments

Comments
 (0)