tailwindcss/packages
Srinu desetti 7a7f386648
Don't emit utilities that resolve a theme value when an unsupported modifier is used (#20419)
## Summary

Modifiers on functional utilities that resolve a named theme value are
silently
dropped instead of invalidating the candidate. For example, with the
default theme:

- `rounded-sm/[5]` emits the same CSS as `rounded-sm` (the `[5]` is
ignored)
- `shadow-sm/foo`, `inset-shadow-sm/foo`, `text-shadow/foo`, and
`drop-shadow/foo`
  emit the full shadow CSS with the invalid `foo` modifier ignored

This is inconsistent with how every sibling code path behaves:
`rounded/foo`,
`rounded-[4px]/foo`, `rounded-sm/5`, and `drop-shadow-xl/foo` all
correctly
produce no output, because those paths check `candidate.modifier`.

This PR adds the missing guards:

- In the generic `functionalUtility` handler, a candidate whose named
value
resolves from the theme now rejects modifiers (except fractions like
`w-1/2`,
  where the modifier is part of the resolved value).
- The `shadow`, `inset-shadow`, and `text-shadow` utilities now apply
the same
`if (candidate.modifier && !alpha) return` guard in their default-value,
arbitrary-value, and named-size branches that `drop-shadow` already
applies,
  and `drop-shadow` gets it in its default-value branch too.

Existing tests asserting candidates like `drop-shadow/foo` produce no
output were
passing for the wrong reason: they run without a theme, so the theme
lookup fails
before the modifier is ever considered. The new tests provide a theme so
the
invalid modifier is what invalidates the candidate.

## Test plan

- Added assertions to the `rounded`, `filter`, `shadow`, `inset-shadow`,
and
`text-shadow` tests that compile candidates with invalid modifiers
against a
theme that defines the relevant values, and expect no output. All of
them fail
  without the fix.
- `pnpm vitest run packages/tailwindcss/src/utilities.test.ts` — 398
passed.

---------

Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2026-08-14 16:47:34 +00:00
..
@tailwindcss-browser Bump dependencies (#20381) 2026-08-04 13:55:03 +02:00
@tailwindcss-cli Bump dependencies (#20381) 2026-08-04 13:55:03 +02:00
@tailwindcss-node Bump dependencies (#20381) 2026-08-04 13:55:03 +02:00
@tailwindcss-postcss Bump dependencies (#20381) 2026-08-04 13:55:03 +02:00
@tailwindcss-standalone Bump dependencies (#20381) 2026-08-04 13:55:03 +02:00
@tailwindcss-turbopack Add Turbopack loader integration coverage 2026-07-31 15:13:38 +02:00
@tailwindcss-upgrade Bump dependencies (#20381) 2026-08-04 13:55:03 +02:00
@tailwindcss-vite Do not force full page reloads when using @tailwindcss/vite (#20414) 2026-08-13 17:00:08 +02:00
@tailwindcss-webpack 4.3.3 (#20334) 2026-07-16 07:21:50 -04:00
internal-example-plugin Prefix internal modules with internal-* (#14074) 2024-07-29 10:58:07 -04:00
tailwindcss Don't emit utilities that resolve a theme value when an unsupported modifier is used (#20419) 2026-08-14 16:47:34 +00:00
tsconfig.base.json Improve debug logs (#15303) 2024-12-11 15:27:20 +01:00