Skip to content

Commit b1ca10a

Browse files
committed
WIP
1 parent ccf24cc commit b1ca10a

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

src/pages/docs/v4-beta.mdx

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,12 +1251,73 @@ If you need more fine-grained control, most utilities can also be configured und
12511251

12521252
### Configuring dark mode
12531253

1254+
By default, the `dark` variant in Tailwind CSS v4.0 uses the `prefers-color-scheme` media query. If you want to use a selector-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 base path 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+
12541272
### Adding content sources
12551273

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`:
1275+
1276+
1277+
```css
1278+
@import "tailwindcss";
1279+
> @source "../node_modules/@my-company/ui-lib/src/components";
1280+
```
1281+
1282+
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:
1283+
1284+
```css {{ filename: '/node_modules/@my-company/ui-lib/index.css' }}
1285+
@source "./src/components";
1286+
```
1287+
1288+
```css {{ filename: 'app.css' }}
1289+
@import "tailwindcss";
1290+
@import "@my-company/ui-lib";
1291+
```
1292+
1293+
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+
12561301
### Disabling source detection
12571302

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+
12581311
### Disabling Preflight
12591312

1313+
If you need to disable Tailwind's base styles, you can import the pieces of Tailwind that you need separately:
1314+
1315+
```css
1316+
@layer theme, base, components, utilities;
1317+
@import "tailwindcss/theme";
1318+
@import "tailwindcss/utilities";
1319+
```
1320+
12601321
### Using a prefix
12611322

12621323
### Adding custom utilities

0 commit comments

Comments
 (0)