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
Next, add our PostCSS plugin to your `postcss.config.js` file:
56
56
57
-
```ts {{ filename: 'postcss.config.mjs' }}
57
+
```js {{ filename: 'postcss.config.mjs' }}
58
58
exportdefault {
59
59
plugins: {
60
60
>'@tailwindcss/postcss': {},
@@ -121,17 +121,171 @@ It's also a good idea to go over all of the [breaking changes](#breaking-changes
121
121
122
122
### CSS-first configuration
123
123
124
-
- CSS-first configuration
124
+
One of the biggest changes in Tailwind CSS v4.0 is the shift from configuring your project in JavaScript to configuring it in CSS.
125
+
126
+
Instead of a `tailwind.config.js` file, you can configure all of your customizations directly in the CSS file where you import Tailwind, giving you one less file to worry about in your project:
The new CSS-first configuration lets you do just about everything you could do in your `tailwind.config.js` file, including configuring your design tokens, setting up content sources, defining custom utilities and variants, installing plugins, and more.
151
+
152
+
To learn more about how it all works, read the [CSS configuration in-depth](#css-configuration-in-depth) documentation.
125
153
126
154
### CSS theme variables
127
155
156
+
Tailwind CSS v4.0 takes all of your design tokens and makes them available as CSS variables by default, so you can reference any value you need at run-time using just CSS.
157
+
158
+
Using the example `@theme` from earlier, all of these values will be added to your CSS to as regular custom properties:
This makes it easy to reuse these values as inline styles or pass them to libraries like [Motion](https://motion.dev/docs/react-animation#css-variables) to animate them.
181
+
128
182
### Native CSS cascade layers
129
183
184
+
We're using real [CSS cascade layers](https://developer.mozilla.org/en-US/docs/Web/CSS/@layer) in v4.0, which make it easier than ever to control the precedence of styles and how they interact with each other.
We've had layers as a concept in Tailwind for years, but native cascade layers can do things that we couldn't easily replicate at build-time, like isolating styles within a layer even if they have a higher specificity than styles in another layer. Less code for us to maintain too!
241
+
130
242
### Automatic source detection
131
243
244
+
You know how you always had to configure that annoying `content` array in Tailwind CSS v3? In v4.0, we came up with a bunch of heuristics for detecting all of that stuff automatically so you don't have to configure it at all.
245
+
246
+
For example, we automatically ignore anything in your `.gitignore` file to avoid scanning dependencies or generated files that aren't under version control:
We also automatically ignore all binary extensions like images, videos, .zip files, and more.
263
+
264
+
And if you ever need to explicitly add a source that's excluded by default, you can always add it with the `@source` directive, right in your CSS file:
The `@source` directive uses the same heuristics under the hood, so it will exclude binary file types for example as well, without you having to specify all of the extensions to scan explicitly.
272
+
132
273
### Built-in import support
133
274
134
-
- Built-in `@import` support
275
+
Before v4.0, if you wanted to inline other CSS files using `@import` you'd have to configure another plugin like `postcss-import` to handle it for you.
276
+
277
+
Now we handle this out of the box, so you don't need to include another plugin:
0 commit comments