Skip to content

Don't generate invalid CSS for *-inherit colors with an opacity modifier - #20679

Merged
RobinMalfait merged 4 commits into
tailwindlabs:mainfrom
solquin:fix/drop-shadow-inherit-modifier
Nov 25, 2026
Merged

RobinMalfait merged 4 commits into
tailwindlabs:mainfrom
solquin:fix/drop-shadow-inherit-modifier

Conversation

@solquin

@solquin solquin commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

#17647 made shadow-inherit, inset-shadow-inherit, text-shadow-inherit and drop-shadow-inherit set the color to inherit, and the first three return nothing when they get an opacity modifier, because inherit can't go inside color-mix(). drop-shadow-inherit/50 still generates it:

.drop-shadow-inherit\/50 {
  --tw-drop-shadow-color: color-mix(in srgb, inherit 50%, transparent);
  @supports (color: color-mix(in lab, red, red)) {
    --tw-drop-shadow-color: color-mix(in oklab, color-mix(in oklab, inherit 50%, transparent) var(--tw-drop-shadow-alpha), transparent);
  }
  --tw-drop-shadow: var(--tw-drop-shadow-size);
}

the drop-shadow color branch does have an inherit case, but it checks the value returned by resolveThemeColor, which has already applied the modifier. so with /50 the value is color-mix(in oklab, inherit 50%, transparent) and the check never matches.

the fix returns early for inherit with a modifier before resolving the color, the same if (candidate.modifier) return the other three utilities use. drop-shadow-inherit without a modifier is unchanged.

Test plan

  • added drop-shadow-inherit/50 and drop-shadow-inherit/[0.5] to the list of drop-shadow candidates that must generate nothing in utilities.test.ts. on main the test fails with the css above; with the fix it passes
  • vitest run src/utilities.test.ts src/intellisense.test.ts in packages/tailwindcss: 421 passed
  • prettier --check on the changed files and pnpm changelog check pass

Combined with #20718

The guard now lives in resolveThemeColor, taken from #20718, so inherit with an opacity modifier generates nothing in all color utilities (e.g. bg-inherit/50, ring-inherit/50 or from-inherit/50), not only in drop-shadow. The early return in the drop-shadow utility is gone, because the shared guard covers it. The tests now also cover bg-inherit/50 and bg-inherit/[0.5], and the changelog entry covers all inherit colors.

Sent by an AI assistant on behalf of @RobinMalfait.

@solquin
solquin requested a review from a team as a code owner November 8, 2026 06:10
@greptile-apps

greptile-apps Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge.

Reviews (7) · Last reviewed commit: "Widen the changelog entry to all `inheri..." · Reviewed by Greptile

@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

resolveThemeColor now rejects inherit candidates with opacity modifiers. Tests cover named and arbitrary opacity modifiers for background and drop-shadow candidates expected to produce no CSS. A changelog entry describes the fix.

Merge Risk: Low · up to 0e2eb

Named inherit colors with opacity modifiers now correctly produce no CSS. Arbitrary inherit values with a modifier can still generate invalid CSS, and autocomplete may still suggest modifier forms that produce nothing. Both are low-impact; fix them or accept them before merging.

Pre-merge checks: Passed 4

Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title names the main change: invalid CSS for *-inherit colors with an opacity modifier is no longer generated. The changeset adds a guard in resolveThemeColor for inherit with a modifier and upd…
Description check Passed The description explains the problem: shadow-inherit utilities and drop-shadow-inherit with an opacity modifier generate invalid color-mix() output with inherit. It describes the fix, the test changes…
Full details: Title check

Explanation

The title names the main change: invalid CSS for *-inherit colors with an opacity modifier is no longer generated. The changeset adds a guard in resolveThemeColor for inherit with a modifier and updates tests and the changelog, so the title matches the changeset. The title is slightly narrower than the final scope, which now covers all color utilities, but it is not misleading.

Full details: Description check

Explanation

The description explains the problem: shadow-inherit utilities and drop-shadow-inherit with an opacity modifier generate invalid color-mix() output with inherit. It describes the fix, the test changes, the verification steps, and the combined scope with PR #20718. It is related to the changeset.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Minor · Exclude invalid inherit opacity completions. · utilities.ts:4766

packages/tailwindcss/src/utilities.ts:4766
Minor · Functional Correctness · Quick win

Exclude invalid inherit opacity completions.

getClassList advertises drop-shadow-inherit/50 even when the color guard makes it generate no CSS. Separate inherit from the modifier-bearing color suggestions, including theme-derived values. Preserve numeric modifier suggestions when --drop-shadow-inherit defines a valid shadow size.

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a929b742-5554-4854-923c-bc085ed0452e
Commits

Reviewing files that changed from the base of the PR and between 9b2c925 and 09aed7a.

Files selected for processing: 3

  • .changelog/drop-shadow-inherit-modifier.md
  • packages/tailwindcss/src/utilities.test.ts
  • packages/tailwindcss/src/utilities.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@solquin

solquin commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

on the completion note from coderabbit: shadow, inset-shadow and text-shadow list -inherit with the same opacity modifiers, and #17647 left those as they are. keeping this pr to the generated css; filtering inherit/* out of the suggestions for all four would fit better in its own change.

@RobinMalfait

Copy link
Copy Markdown
Contributor

I rebased this PR on the latest main and force pushed it.

Sent by an AI assistant on behalf of @RobinMalfait.

@RobinMalfait RobinMalfait changed the title Don't generate invalid CSS for drop-shadow-inherit with an opacity modifier Don't generate invalid CSS for *-inherit colors with an opacity modifier Nov 16, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4b42b84d-17c1-4099-865f-b557c526f80a
Commits

Reviewing files that changed from the base of the PR and between e34b1be and 0e2eb94.

Files selected for processing: 3

  • .changelog/inherit-color-opacity-modifier.md
  • packages/tailwindcss/src/utilities.test.ts
  • packages/tailwindcss/src/utilities.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Comment thread packages/tailwindcss/src/utilities.ts Resolved
@RobinMalfait
RobinMalfait force-pushed the fix/drop-shadow-inherit-modifier branch from 0e2eb94 to b98bca6 Compare November 25, 2026 12:56
@RobinMalfait
RobinMalfait enabled auto-merge (squash) November 25, 2026 12:56

@RobinMalfait RobinMalfait left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, and for the clear write-up of why the old inherit check never matched!

Sent by an AI assistant on behalf of @RobinMalfait.

solquin and others added 4 commits November 25, 2026 14:05
…ifier

`inherit` is a CSS-wide keyword, so it can't go inside `color-mix()`.
Utilities like `bg-inherit/50` generated
`color-mix(in oklab, inherit 50%, transparent)`, which the browser
drops. Return `null` from `resolveThemeColor` for `inherit` with a
modifier, so all color utilities generate nothing, like
`shadow-inherit/50` already does.

Taken from tailwindlabs#20718.

Co-authored-by: sudeepgowda55 <ssudeepgowda55@gmail.com>
…overs

`resolveThemeColor` returns `null` for `inherit` with a modifier now, so
the early return in the drop-shadow utility never runs. The tests for
`drop-shadow-inherit/50` and `drop-shadow-inherit/[0.5]` still pass.
Move its explanation to the shared guard.
The fix now covers all color utilities, like `bg-inherit/50`, not only
`drop-shadow-inherit/50`. Rename the fragment to match.
@RobinMalfait
RobinMalfait force-pushed the fix/drop-shadow-inherit-modifier branch from b98bca6 to ed404f4 Compare November 25, 2026 13:05
@RobinMalfait
RobinMalfait merged commit 4a751d1 into tailwindlabs:main Nov 25, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants