You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Tailwind CSS v3 tailwind-merge was in a difficult position with the Tailwind's theme scales. If tailwind-merge implemented support for all theme scales, the bundle size would become twice as large. If it didn't support any theme scales, users would have had a difficult time extending scales that are used in many class groups, like in the case of the `spacing` scale. tailwind-merge went with an awkward middle ground where it only supported theme scales that were used in multiple class groups.
41
+
In Tailwind CSS v3 tailwind-merge was in a difficult position with Tailwind's theme scales. If tailwind-merge implemented support for all theme scales, the bundle size would become twice as large. If it didn't support any theme scales, users would have had a difficult time extending scales that are used in many class groups, like in the case of the `spacing` scale. tailwind-merge went with an awkward middle ground where it only supported theme scales that were used in multiple class groups.
42
42
43
43
Tailwind CSS v4 reduced the number of theme scales to only 18 (called [theme variable namespaces](https://tailwindcss.com/docs/theme#theme-variable-namespaces) now) which makes it possible for tailwind-merge to support all of them.
Here's how to proceed with upgrading each individual theme scale that got removed or renamed. Just keep in mind that theme scales should only define the custom part of a class (i.e. `deep` for the class `inset-shadow-deep`) whereas class groups should define the whole class (i.e. `inset-shadow-deep` for the class `inset-shadow-deep`). Sometimes you might find that values you configured manually before are now supported by Tailwind CSS v4 by default in which case you can remove them from your tailwind-merge config.
62
62
63
-
-`borderColor`: Use the theme scale `color` instead
64
-
-`borderRadius`: Use the theme scale `radius` instead
65
-
-`borderSpacing`: Use the theme scale `spacing` or class groups `border-spacing-*` instead
66
-
-`borderWidth`: Use the class groups `border-w-*` instead
67
-
-`brightness`: Use the class groups `brightness` and `backdrop-brightness` instead
68
-
-`colors`: Use the theme scale `color` instead
69
-
-`contrast`: Use the class groups `contrast` and `backdrop-contrast` instead
70
-
-`gap`: Use the class groups `gap-*` instead
71
-
-`gradientColorStopPositions`: Use the class groups `gradient-from-pos`, `gradient-via-pos` and `gradient-to-pos` instead
72
-
-`gradientColorStops`: Use the class groups `gradient-from`, `gradient-via` and `gradient-to` instead
73
-
-`grayscale`: Use the class groups `grayscale` and `backdrop-grayscale` instead
74
-
-`hueRotate`: Use the class groups `hue-rotate` and `backdrop-hue-rotate` instead
75
-
-`inset`: Use the theme scale `spacing` or class groups `inset-*` instead
76
-
-`invert`: Use the class groups `invert` and `backdrop-invert` instead
77
-
-`margin`: Use the theme scale `spacing` or class groups `m-*` instead
78
-
-`opacity`: Use class groups `opacity` and `backdrop-opacity` instead
79
-
-`padding`: Use the theme scale `spacing` or class groups `p-*` instead
80
-
-`saturate`: use the class groups `saturate` and `backdrop-saturate` instead
81
-
-`scale`: Use the class groups `scale-*` instead
82
-
-`sepia`: Use the class groups `sepia` and `backdrop-sepia` instead
83
-
-`skew`: use the class groups `skew-*` instead
84
-
-`space`: Use the theme scale `spacing` or class groups `space-*` instead
85
-
-`translate`: Use the theme scale `spacing` or class groups `translate-*` instead
63
+
| Theme scale in tailwind-merge v2 | What to use in tailwind-merge v3 instead |
|`borderSpacing`| theme scale `spacing` or class groups `border-spacing-*`|
68
+
|`borderWidth`| class groups `border-w-*`|
69
+
|`brightness`| class groups `brightness` and `backdrop-brightness`|
70
+
|`colors`| theme scale `color`|
71
+
|`contrast`| class groups `contrast` and `backdrop-contrast`|
72
+
|`gap`| class groups `gap-*`|
73
+
|`gradientColorStopPositions`| class groups `gradient-from-pos`, `gradient-via-pos` and `gradient-to-pos`|
74
+
|`gradientColorStops`| class groups `gradient-from`, `gradient-via` and `gradient-to`|
75
+
|`grayscale`| class groups `grayscale` and `backdrop-grayscale`|
76
+
|`hueRotate`| class groups `hue-rotate` and `backdrop-hue-rotate`|
77
+
|`inset`| theme scale `spacing` or class groups `inset-*`|
78
+
|`invert`| class groups `invert` and `backdrop-invert`|
79
+
|`margin`| theme scale `spacing` or class groups `m-*`|
80
+
|`opacity`| class groups `opacity` and `backdrop-opacity`|
81
+
|`padding`| theme scale `spacing` or class groups `p-*`|
82
+
|`saturate`| class groups `saturate` and `backdrop-saturate`|
83
+
|`scale`| class groups `scale-*`|
84
+
|`sepia`| class groups `sepia` and `backdrop-sepia`|
85
+
|`skew`| class groups `skew-*`|
86
+
|`space`| theme scale `spacing` or class groups `space-*`|
87
+
|`translate`| theme scale `spacing` or class groups `translate-*`|
86
88
87
89
In case you were modifying class groups in tailwind-merge v2 because their theme scale was previously not implemented, it is highly likely that you can move those definitions to the `theme` object in tailwind-merge v3. E.g. if you previously modified the `font-family` class group to add a custom font class, you can now use `theme.font` instead. Check out the [theme documentation](../configuration.md#theme) for more info.
88
90
@@ -161,7 +163,7 @@ Add the `orderSensitiveModifiers` field to your tailwind-merge config.
161
163
162
164
#### Full upgrade
163
165
164
-
If you have any order-sensitive modifiers in Tailwind, ddd them to the new `orderSensitiveModifiers` field in your tailwind-merge config.
166
+
If you have any order-sensitive modifiers in Tailwind, add them to the new `orderSensitiveModifiers` field in your tailwind-merge config.
165
167
166
168
```diff
167
169
import { createTailwindMerge } from 'tailwind-merge'
@@ -176,7 +178,7 @@ If you have any order-sensitive modifiers in Tailwind, ddd them to the new `orde
176
178
177
179
The validator `isLength` was used to check whether a class part is a number (`3`, `1.5`), a fraction (`3/4`), or one of the strings `px`, `full` or `screen`. This was used for most length-based scales but the name was not really precise in explaining what it allows.
178
180
179
-
Due to how length-based scales were changed in Tailwind CSS v4, tailwind-merge v3 now uses `isNumber` and `isFraction` instead depending on what each scale supports and strings like `px`, `full` and `screen` are instead specified manually in the scales themselves. That makes it more obvious what those validators do.
181
+
Due to how length-based scales were changed in Tailwind CSS v4, tailwind-merge v3 now uses `isNumber` and `isFraction` instead depending on what each scale supports and strings like `px`, `full` and `screen` are instead specified manually in the scales themselves. This makes it more obvious what those validators do.
Copy file name to clipboardexpand all lines: docs/changelog/v3-changelog.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ Check out the [migration guide](./v2-to-v3-migration.md) and if you have any que
14
14
- Prefix defined in config shouldn't include combining `-` character anymore by [@dcastil](https://github.com/dcastil) in [#518](https://github.com/dcastil/tailwind-merge/pull/518)
15
15
- Tailwind CSS v3 prefix position in class not supported anymore in favor of Tailwind CSS v4 position by [@dcastil](https://github.com/dcastil) in [#518](https://github.com/dcastil/tailwind-merge/pull/518)
16
16
- Custom separators are no longer supported by [@dcastil](https://github.com/dcastil) in [#518](https://github.com/dcastil/tailwind-merge/pull/518)
17
-
- New mandatory `orderSensitiveModifiers` property in config when using `createTailwindMerge`, etc. by [@dcastil](https://github.com/dcastil) in [#518](https://github.com/dcastil/tailwind-merge/pull/518)
17
+
- New mandatory `orderSensitiveModifiers` property in config when using `createTailwindMerge` by [@dcastil](https://github.com/dcastil) in [#518](https://github.com/dcastil/tailwind-merge/pull/518)
18
18
-`DefaultThemeGroupIds` type union consists of different string literals than before by [@dcastil](https://github.com/dcastil) in [#518](https://github.com/dcastil/tailwind-merge/pull/518)
19
19
- Classes removed in Tailwind CSS v4 are not supported by tailwind-merge anymore by [@dcastil](https://github.com/dcastil) in [#518](https://github.com/dcastil/tailwind-merge/pull/518)
Copy file name to clipboardexpand all lines: docs/configuration.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -143,7 +143,7 @@ In Tailwind CSS, not all modifiers behave the same when you stack them.
143
143
144
144
In most cases the order of modifiers doesn't matter. E.g. `hover:focus:bg-red-500` and `focus:hover:bg-red-500` behave the same and in the context of tailwind-merge, you'd want them both to override each other. tailwind-merge sorts the modifiers internally to be able to override classes with the same modifiers, even if they are in a different order.
145
145
146
-
However, there are some modifiers where the order matters, e.g. the direct children modifier `*`. The class `*:hover:text-red-500` modifies the text color of a child if that child is hovered, but the class `hover:*:text-red-500` modifies the text color of all direct children if the parent is hovered. In this case, you would want tailwind-merge to preserve both classes although they have the same modifiers, just in a different order.
146
+
However, there are some modifiers where the order matters, e.g. the direct children modifier `*`. The class `*:hover:text-red-500` modifies the text color of a child if that particular child is hovered, but the class `hover:*:text-red-500` modifies the text color of all direct children if the parent is hovered. In this case, you would want tailwind-merge to preserve both classes although they have the same modifiers, just in a different order.
147
147
148
148
To know which modifiers are order-sensitive, tailwind-merge has the `orderSensitiveModifiers` property in its config. `twMerge` is pre-configured with all the order-sensitive modifiers that Tailwind CSS has by default. You'll only need to configure this property if you add your own order-sensitive modifiers or change the meaning of the default order-sensitive modifiers.
0 commit comments