Skip to content

Fix drop-shadow ignoring its opacity modifier when no size is specified - #20445

Open
koreahghg wants to merge 2 commits into
tailwindlabs:mainfrom
koreahghg:fix/drop-shadow-alpha-modifier
Open

Fix drop-shadow ignoring its opacity modifier when no size is specified#20445
koreahghg wants to merge 2 commits into
tailwindlabs:mainfrom
koreahghg:fix/drop-shadow-alpha-modifier

Conversation

@koreahghg

Copy link
Copy Markdown
Contributor

Summary

The bare drop-shadow utility (no size keyword, e.g. drop-shadow/50) ignored its opacity modifier and always rendered with the theme's default alpha instead.

In createUtilities's drop-shadow handler (packages/tailwindcss/src/utilities.ts), the !candidate.value branch (bare drop-shadow) correctly computed the alpha-adjusted shadow into --tw-drop-shadow-size, but then unconditionally overwrote --tw-drop-shadow — the variable actually referenced by filter: var(--tw-drop-shadow, ) — with the raw, unmodified theme value, discarding the alpha entirely.

Every sibling branch (arbitrary value/color, and the named-size branch, e.g. drop-shadow-lg/50) already handles this correctly by branching on whether a modifier alpha is present and pointing --tw-drop-shadow at var(--tw-drop-shadow-size) in that case. This PR applies the same branch to the bare drop-shadow utility.

Before:

.drop-shadow\/50 {
  --tw-drop-shadow-alpha: 50%;
  --tw-drop-shadow-size: drop-shadow(0 1px 2px var(--tw-drop-shadow-color, oklab(0% 0 0 / .5))) drop-shadow(0 1px 1px var(--tw-drop-shadow-color, oklab(0% 0 0 / .5)));
  --tw-drop-shadow: drop-shadow(0 1px 2px #0000001a) drop-shadow(0 1px 1px #0000000f); /* still the theme default alpha, not 50% */
  filter: ... var(--tw-drop-shadow, );
}

After:

.drop-shadow\/50 {
  --tw-drop-shadow-alpha: 50%;
  --tw-drop-shadow-size: drop-shadow(0 1px 2px var(--tw-drop-shadow-color, oklab(0% 0 0 / .5))) drop-shadow(0 1px 1px var(--tw-drop-shadow-color, oklab(0% 0 0 / .5)));
  --tw-drop-shadow: var(--tw-drop-shadow-size);
  filter: ... var(--tw-drop-shadow, );
}

Test plan

  • The existing filter test in packages/tailwindcss/src/utilities.test.ts already exercises drop-shadow/25 and drop-shadow/12.5; its inline snapshot previously asserted the buggy (unmodified-alpha) output. Updated the snapshot to reflect the corrected behavior via npx vitest run packages/tailwindcss/src/utilities.test.ts -t "^filter$" -u, and confirmed the diff only changes --tw-drop-shadow: drop-shadow(var(--drop-shadow))--tw-drop-shadow: var(--tw-drop-shadow-size) for the two alpha-modified cases.
  • npx vitest run packages/tailwindcss/src/utilities.test.ts — all 398 tests pass.
  • npx vitest run packages/tailwindcss/src/intellisense.test.ts packages/tailwindcss/src/index.test.ts — all 277 tests pass (no regressions in related suites).
  • npx prettier --check packages/tailwindcss/src/utilities.ts packages/tailwindcss/src/utilities.test.ts — passes.
  • npx tsc --noEmit — no new type errors introduced by this change.

…fied

The bare `drop-shadow` utility (no size keyword, e.g. `drop-shadow/50`)
computed the alpha-adjusted shadow into `--tw-drop-shadow-size` but never
wired it into `--tw-drop-shadow`, the variable actually consumed by
`filter`. It always fell back to the theme's default alpha instead.

Named sizes (`drop-shadow-lg/50`) already handled this correctly by
branching on whether a modifier alpha was present; apply the same
branch to the bare utility.
@koreahghg
koreahghg requested a review from a team as a code owner August 31, 2026 07:04
@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 68bea289-b6ec-4142-b721-72fb7ade925f

📥 Commits

Reviewing files that changed from the base of the PR and between 90f8ff4 and 98c8ffe.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • packages/tailwindcss/src/utilities.test.ts
  • packages/tailwindcss/src/utilities.ts

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


Walkthrough

Updated named drop-shadow utilities with opacity modifiers to derive --tw-drop-shadow from the alpha-replaced --tw-drop-shadow-size variable. Updated tests for 12.5% and 25% variants. Added an Unreleased changelog entry for size-less drop-shadow opacity modifiers.

Merge Risk: ⚪ Minimal · up to 98c8f

This change makes opacity modifiers work correctly for size-less drop-shadow utilities without altering other shadow behavior; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: fixing opacity modifiers for bare drop-shadow utilities when no size is specified.
Description check ✅ Passed The description directly explains the bug, the implementation change, the affected variables, the test updates, and the validation results.
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.

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

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge with no actionable correctness, security, or quality issues identified.

The changed branch correctly activates the already-computed alpha-adjusted drop-shadow value and follows the established implementation used for named drop-shadow sizes.

Reviews (1): Last reviewed commit: "Add changelog entry for drop-shadow opac..." | Re-trigger Greptile

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.

1 participant