Skip to content

Commit 95d3b12

Browse files
Improve upgrade guide (#2096)
Closes #2015 - Mention that `corePlugins`, `safelist`, and `seperator` no longer exist in v4 - Mention `@layer components` in the `@layer utilities` section
1 parent 1ac908c commit 95d3b12

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/docs/functions-and-directives.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ Use the `@config` directive to load a legacy JavaScript-based configuration file
252252
@config "../../tailwind.config.js";
253253
```
254254

255-
The `corePlugins`, `safelist` and `separator` options from the JavaScript-based config are not supported in v4.0.
255+
The `corePlugins`, `safelist`, and `separator` options from the JavaScript-based config are not supported in v4.0.
256256

257257
<h3 id="plugin-directive">@plugin</h3>
258258

src/docs/upgrade-guide.mdx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ The generated CSS variables _will_ include a prefix to avoid conflicts with any
595595

596596
### Adding custom utilities
597597

598-
In v3, any custom classes you defined within `@layer utilities` would get picked up by Tailwind as a true utility class and would automatically work with variants like `hover`, `focus`, or `lg`.
598+
In v3, any custom classes you defined within `@layer utilities` or `@layer components` would get picked up by Tailwind as a true utility class and would automatically work with variants like `hover`, `focus`, or `lg` with the difference being that `@layer components` would always come first in the generated stylesheet.
599599

600600
In v4 we are using native cascade layers and no longer hijacking the `@layer` at-rule, so we've introduced the `@utility` API as a replacement:
601601

@@ -613,6 +613,26 @@ In v4 we are using native cascade layers and no longer hijacking the `@layer` at
613613
}
614614
```
615615

616+
Custom utilities are now also sorted based on the amount of properties they define. This means that component utilities like this `.btn` can be overwritten by other Tailwind utilities without additional configuration:
617+
618+
```css
619+
/* [!code filename:CSS] */
620+
/* [!code --:8] */
621+
@layer components {
622+
.btn {
623+
border-radius: 0.5rem;
624+
padding: 0.5rem 1rem;
625+
background-color: ButtonFace;
626+
}
627+
}
628+
/* [!code ++:6] */
629+
@utility btn {
630+
border-radius: 0.5rem;
631+
padding: 0.5rem 1rem;
632+
background-color: ButtonFace;
633+
}
634+
```
635+
616636
Learn more about registering custom utilities in the [adding custom utilities documentation](/docs/adding-custom-styles#adding-custom-utilities).
617637

618638
### Variant stacking order
@@ -725,6 +745,8 @@ If you still need to use a JavaScript config file, you can load it explicitly us
725745
@config "../../tailwind.config.js";
726746
```
727747

748+
The `corePlugins`, `safelist`, and `separator` options from the JavaScript-based config are not supported in v4.0.
749+
728750
### Theme values in JavaScript
729751

730752
In v3 we exported a `resolveConfig` function that you could use to turn your JavaScript-based config into a flat object that you could use in your other JavaScript.

0 commit comments

Comments
 (0)