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
Copy file name to clipboardExpand all lines: src/pages/docs/v4-beta.mdx
+61Lines changed: 61 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1251,12 +1251,73 @@ If you need more fine-grained control, most utilities can also be configured und
1251
1251
1252
1252
### Configuring dark mode
1253
1253
1254
+
By default, the `dark` variant in Tailwind CSS v4.0 uses the `prefers-color-scheme` media query. If you want to useaselector-based strategy in your project for dark mode, override the `dark` variant with the selector you want to use:
1255
+
1256
+
```css
1257
+
@import"tailwindcss";
1258
+
1259
+
>@variant dark (&:where(.dark, .dark *));
1260
+
```
1261
+
1262
+
### Configuring source detection
1263
+
1264
+
If the automatic source detection in Tailwind CSS v4.0 is too broad and including files you don't want it to include (maybe you're working in a large monorepo for example), you can use the `source(…)` function when importing Tailwind to specify the basepath for automatic source detection:
1265
+
1266
+
```css
1267
+
@import"tailwindcss" source("../src");
1268
+
```
1269
+
1270
+
This path should be relative to the CSS file where it's used.
1271
+
1254
1272
### Adding content sources
1255
1273
1274
+
If you need to add additional content sources that aren't being picked up by default (like something that is in your `.gitignore` file), add it using `@source`:
For situations like this, it can also be helpful to export a CSS file from your library and move the `@source` directive there instead so you can just import the CSS file:
The `@source` directive can also be useful when you're using the Vite plugin but need to include content sources that aren't naturally part of the module graph, like PHP templates in a Laravel project:
1294
+
1295
+
```css
1296
+
@import"tailwindcss";
1297
+
>@source "../../resources/views";
1298
+
>@source "../../app";
1299
+
```
1300
+
1256
1301
### Disabling source detection
1257
1302
1303
+
If you need disable automatic source detection for any reason, use `source(none)` when importing Tailwind:
1304
+
1305
+
```css
1306
+
@import"tailwindcss" source(none);
1307
+
```
1308
+
1309
+
With source detection disabled, you can then just use `@source` to configure all of your content sources explicitly.
1310
+
1258
1311
### Disabling Preflight
1259
1312
1313
+
If you need to disable Tailwind'sbase styles, you can import the pieces of Tailwind that you need separately:
0 commit comments