Skip to content

Commit cac03b2

Browse files
committed
WIP
1 parent b1ca10a commit cac03b2

File tree

1 file changed

+134
-6
lines changed

1 file changed

+134
-6
lines changed

src/pages/docs/v4-beta.mdx

Lines changed: 134 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ We've finally added APIs for doing 3D transforms, like `rotate-x-*`, `rotate-y-*
714714
</div>
715715
<h3 class="mt-3 text-lg/6 font-semibold text-white">
716716
<span class="absolute inset-0"></span>
717-
Boost your conversion rate
717+
Boost your conversion rate
718718
</h3>
719719
</article>
720720
</div>
@@ -730,7 +730,7 @@ We've finally added APIs for doing 3D transforms, like `rotate-x-*`, `rotate-y-*
730730
Use the `transform-3d` utility to enable 3D transforms by setting the right `transform-style`
731731

732732

733-
#### Rotate
733+
#### Rotate
734734
Use the `rotate-x-*`, `rotate-y-*` and `rotate-z-*` utilities to rotate elements in 3D space.
735735

736736

@@ -780,7 +780,7 @@ Use the `scale-z-*` utilities to scale elements on the z-axis.
780780
'scale-z-125': {'--tw-scale-z': '125%'},
781781
'scale-z-150': {'--tw-scale-z': '150%'},
782782
'scale-z-200': {'--tw-scale-z': '200%'},
783-
783+
784784
}}/>
785785

786786
#### Translate
@@ -1239,7 +1239,7 @@ Since we've dramatically [simplified theme configuration](#simplified-theme-conf
12391239
| `--tracking-*` | Letter spacing utilities like `tracking-tight` |
12401240
| `--leading-*` | Line height utilities like `leading-relaxed` |
12411241
| `--breakpoint-*` | Breakpoint variants like `md:*` and `lg:*` |
1242-
| `--container-*` | Container query variants like `@sm:*` and `@lg:*`\nmax-width utilities like `max-w-lg` |
1242+
| `--container-*` | Container query variants like `@sm:*` and `@lg:*` and max-width utilities like `max-w-lg` |
12431243
| `--radius-*` | Border radius utilities like `rounded-md` |
12441244
| `--shadow-*` | Box shadow utilities like `shadow-lg` |
12451245
| `--inset-shadow-*` | Inset box shadow utilities like `inset-shadow-sm` |
@@ -1251,11 +1251,12 @@ 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:
1254+
By default, the `dark` variant in Tailwind CSS v4.0 uses the `prefers-color-scheme` media query.
1255+
1256+
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:
12551257

12561258
```css
12571259
@import "tailwindcss";
1258-
12591260
> @variant dark (&:where(.dark, .dark *));
12601261
```
12611262

@@ -1320,16 +1321,141 @@ If you need to disable Tailwind's base styles, you can import the pieces of Tail
13201321

13211322
### Using a prefix
13221323

1324+
To prefix your utilities and theme variables to avoid conflicts with existing CSS, use the `prefix(…)` function when importing Tailwind:
1325+
1326+
```css
1327+
@import "tailwindcss" prefix(tw);
1328+
```
1329+
1330+
Prefixes work a little differently than in v3 — now they look like variants and are always at the beginning of the class name:
1331+
1332+
```html
1333+
<div class="**tw:flex** **tw:bg-red-500** **tw:hover:bg-red-600**">
1334+
<!-- ... -->
1335+
</div>
1336+
```
1337+
1338+
When using a prefix, you should still configure your theme variables as if you aren't using a prefix:
1339+
1340+
```css {{ filename: "app.css" }}
1341+
@import "tailwindcss" prefix(tw);
1342+
1343+
@theme {
1344+
--font-display: "Satoshi", "sans-serif";
1345+
1346+
--breakpoint-3xl: 1920px;
1347+
1348+
--color-avocado-100: oklch(0.99 0 0);
1349+
--color-avocado-200: oklch(0.98 0.04 113.22);
1350+
--color-avocado-300: oklch(0.94 0.11 115.03);
1351+
1352+
/* ... */
1353+
}
1354+
```
1355+
1356+
The generated CSS variables _will_ include a prefix though to avoid conflicts with any existing variables in your project:
1357+
1358+
```css {{ filename: "dist.css" }}
1359+
:root {
1360+
--tw-font-display: "Satoshi", "sans-serif";
1361+
1362+
--tw-breakpoint-3xl: 1920px;
1363+
1364+
--tw-color-avocado-100: oklch(0.99 0 0);
1365+
--tw-color-avocado-200: oklch(0.98 0.04 113.22);
1366+
--tw-color-avocado-300: oklch(0.94 0.11 115.03);
1367+
1368+
/* ... */
1369+
}
1370+
```
1371+
13231372
### Adding custom utilities
13241373

1374+
To add a custom utility in v4.0, use the new `@utility` directive:
1375+
1376+
```css
1377+
@import "tailwindcss";
1378+
1379+
@utility tab-4 {
1380+
tab-size: 4;
1381+
}
1382+
```
1383+
1384+
Custom utilities are automatically inserted into the `utilities` layer along with all of the built-in utilities in the framework.
1385+
13251386
### Adding custom variants
13261387

1388+
To add a custom variant in v4.0, use the new `@variant` directive:
1389+
1390+
```css
1391+
@import "tailwindcss";
1392+
1393+
@variant pointer-coarse (@media (pointer: coarse));
1394+
@variant theme-midnight (&:where([data-theme="midnight"] *));
1395+
```
1396+
1397+
This lets you write utilities like `pointer-coarse:size-48` and `theme-midnight:bg-slate-900`.
1398+
13271399
### Using plugins
13281400

1401+
To load a plugin in v4.0, use the the new `@plugin` directive:
1402+
1403+
```css
1404+
@import "tailwindcss";
1405+
1406+
@plugin "@tailwindcss/typography";
1407+
```
1408+
1409+
The `@plugin` directive takes either a package name or a local path.
1410+
13291411
### Using legacy configuration files
13301412

1413+
To use an existing JS configuration file in v4.0, load it with the `@config` directive:
1414+
1415+
```css
1416+
@import "tailwindcss";
1417+
1418+
@config "../../tailwind.config.js";
1419+
```
1420+
1421+
Note that not every feature of the JS config is supported in v4.0. Options like `corePlugins`, `important`, and `separator` will likely not be supported at all in the stable v4.0 release, and options like `safelist` may return but with differences in behavior.
1422+
13311423
### Using \`@apply\` in Vue/Svelte
13321424

1425+
If you want to use `@apply` in the `<style>` block of a Vue or Svelte component, you will need to import your theme configuration to make those values available in that context.
1426+
1427+
To do this without duplicating the CSS variables in your CSS output, use `theme(reference)` when importing your theme:
1428+
1429+
```html
1430+
<template>
1431+
<h1>Hello world!</h1>
1432+
</template>
1433+
1434+
<style>
1435+
> @import "../../my-theme.css" theme(reference);
1436+
1437+
h1 {
1438+
@apply font-bold text-2xl text-red-500;
1439+
}
1440+
</style>
1441+
```
1442+
1443+
If you're just using the default theme, you can import `"tailwindcss/theme"` directly:
1444+
1445+
```html
1446+
<template>
1447+
<h1>Hello world!</h1>
1448+
</template>
1449+
1450+
<style>
1451+
> @import "tailwindcss/theme" theme(reference);
1452+
1453+
h1 {
1454+
@apply font-bold text-2xl text-red-500;
1455+
}
1456+
</style>
1457+
```
1458+
13331459
---
13341460

13351461
## Breaking changes
@@ -1370,6 +1496,8 @@ If you need to disable Tailwind's base styles, you can import the pieces of Tail
13701496

13711497
### Core plugins cannot be disabled
13721498

1499+
### Using the \`theme()\` function
1500+
13731501
### Using a JavaScript config file
13741502

13751503
- Not autodetected, need to use `@config`

0 commit comments

Comments
 (0)