tailwindcss/packages
Jordan Pittman 2030e942bc
Don't consider the global important state in @apply (#18404)
Fixes #18400

In v3 when you used `important: true` it did not affect `@apply`.
However, in v4 it does and there's no way to make it *not*. This is
definitely a bug and would be unexpected for users coming from v3 who
use `@apply` and `important` together.

Basically, the following code, along with the detected utility `flex` in
source files…

```css
@import 'tailwindcss/utilities' important;
.flex-explicitly-important {
  @apply flex!;
}
.flex-not-important {
  @apply flex;
}
```

… would output this:
```css
.flex {
  display: flex !important;
}
.flex-explicitly-important  {
  display: flex !important;
}
.flex-not-important {
  display: flex !important;
}
```

But it's expected that `@apply` doesn't consider the "global" important
state. This PR addresss this problem and now the output is this:

```css
.flex {
  display: flex !important;
}
.flex-explicitly-important  {
  display: flex !important;
}
.flex-not-important {
  display: flex; /* this line changed */
}
```

If you want to mark a utility as important in `@apply` you can still use
`!` after the utility to do so as shown above.

---------

Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2025-06-27 11:55:15 -04:00
..
@tailwindcss-browser Prepare 4.1.11 (#18397) 2025-06-26 12:43:17 +02:00
@tailwindcss-cli Prepare 4.1.11 (#18397) 2025-06-26 12:43:17 +02:00
@tailwindcss-node Prepare 4.1.11 (#18397) 2025-06-26 12:43:17 +02:00
@tailwindcss-postcss Prepare 4.1.11 (#18397) 2025-06-26 12:43:17 +02:00
@tailwindcss-standalone Prepare 4.1.11 (#18397) 2025-06-26 12:43:17 +02:00
@tailwindcss-upgrade Don't consider the global important state in @apply (#18404) 2025-06-27 11:55:15 -04:00
@tailwindcss-vite Prepare 4.1.11 (#18397) 2025-06-26 12:43:17 +02:00
internal-example-plugin Prefix internal modules with internal-* (#14074) 2024-07-29 10:58:07 -04:00
tailwindcss Don't consider the global important state in @apply (#18404) 2025-06-27 11:55:15 -04:00
tsconfig.base.json Improve debug logs (#15303) 2024-12-11 15:27:20 +01:00