Skip to content

Commit c62bd12

Browse files
committed
WIP
1 parent 345e4f7 commit c62bd12

File tree

1 file changed

+7
-301
lines changed

1 file changed

+7
-301
lines changed

src/pages/blog/tailwindcss-v4-beta/index.mdx

Lines changed: 7 additions & 301 deletions
Original file line numberDiff line numberDiff line change
@@ -22,307 +22,13 @@ About eight months ago we [open-sourced our progress](https://tailwindcss.com/bl
2222

2323
As I talked about when we published the first alpha, Tailwind CSS v4.0 is an all-new engine built for performance, and designed for the modern web.
2424

25-
- **
25+
- **Built for performance** — full builds in the new engine are up to 5x faster, and incremental builds are over 100x faster — and measured in microseconds.
26+
- **Unified toolchain** — build-in import handling, vendor prefixing, and syntax transforms, with no additional tooling required.
27+
- **CSS-first configuration** — a reimagined developer experience where you customize and extend the framework directly in CSS instead of a JavaScript configuration file.
28+
- **Designed for the modern web** — built on native cascade layers, wide-gamut colors, and including first-class support for modern CSS features like container queries, `@starting-style`, popovers, and more.
2629

27-
---
30+
There's so much more to say, but everything you need to get started is in the new beta documentation we published today:
2831

29-
## A new engine, built for speed
32+
[Get started with Tailwind CSS v4.0 Beta 1 →](/docs/v4-beta)
3033

31-
The new engine is a ground-up rewrite, using everything we know about the framework now to better model the problem space, making things faster with a lot less code.
32-
33-
- **Up to 10x faster** — we can do a full build of the Tailwind CSS website in 105ms instead of 960ms, or our Catalyst UI kit in 55ms instead of 341ms.
34-
- **Smaller footprint** — the new engine is over 35% smaller installed, even with the heavier native packages we ship like the parts we've rewritten in Rust and Lightning CSS.
35-
- **Rust where it counts** — we've migrated some of the most expensive and parallelizable parts of the framework to Rust, while keeping the core of the framework in TypeScript for extensibility.
36-
- **One dependency** — the only thing the new engine depends on is Lightning CSS.
37-
- **Custom parser** — we wrote our own CSS parser and designed our own data structures tailored to our needs, making parsing over 2x as fast for us as it was with PostCSS.
38-
39-
---
40-
41-
## Unified toolchain
42-
43-
Tailwind CSS v4 isn't just a plugin anymore — it's an all-in-one tool for processing your CSS. We've integrated [Lightning CSS](https://lightningcss.dev/) directly into the framework so you don't have to configure anything about your CSS pipeline.
44-
45-
- **Built-in `@import` handling** — no need to setup and configure a tool like `postcss-import`.
46-
- **Built-in vendor prefixing** — you don't have to add `autoprefixer` to your projects anymore.
47-
- **Built-in nesting support** — no plugins needed to flatten nested CSS, it works out of the box.
48-
- **Syntax transforms** — modern CSS features like `oklch()` colors and media query ranges are transpiled to syntax with better browser support.
49-
50-
We're still shipping a PostCSS plugin, but we're also exploring first-party bundler plugins, and we're shipping an official Vite plugin with this first alpha release that you can try out today.
51-
52-
---
53-
54-
## Designed for the modern web
55-
56-
We're looking into the future with Tailwind CSS v4 and trying to build a framework that's going to feel cutting edge for years to come.
57-
58-
- **Native cascade layers** — we're using real `@layer` rules now, which solves a ton of specificity problems we've wrestled with in the past.
59-
- **Explicitly defined custom properties** — we use `@property` to define our internal custom properties with proper types and constraints, making it possible to do things like transition background gradients.
60-
- **Using `color-mix` for opacity modifiers** — making it easier than ever to use our opacity modifier syntax when using CSS variables for colors, or even adjusting the opacity of `currentColor`.
61-
- **Container queries in core** — we've added support for container queries directly to core, with new `@min-*` and `@max-*` variants to support container query ranges.
62-
63-
We're also working on refreshing our color palette with wide gamut colors, and introducing support for other modern CSS features like `@starting-style`, anchor positioning, and more.
64-
65-
---
66-
67-
## Composable variants
68-
69-
The new architecture makes it possible to compose together variants that act on other selectors, like `group-*`, `peer-*`, `has-*`, and a new `not-*` variant we're introducing for v4.
70-
71-
In earlier releases, variants like `group-has-*` were explicitly defined in the framework, but now `group-*` can compose with the existing `has-*` variant, which can compose with other variants like `focus`:
72-
73-
```diff-html {{ filename: 'index.html', style: 'framed', color: 'pink' }}
74-
<div class="group">
75-
- <div class="group-has-[&:focus]:opacity-100">
76-
+ <div class="group-has-focus:opacity-100">
77-
<!-- ... -->
78-
</div>
79-
</div>
80-
```
81-
82-
There's no limits to this composability, and you can even write stuff like `group-not-has-peer-not-data-active:underline` if for some horrible reason that's what you need to do.
83-
84-
---
85-
86-
## Zero-configuration content detection
87-
88-
You'll notice that at least in these early alpha releases, it's not even possible to configure your `content` paths. For most projects, you're never going to need to do this ever again — Tailwind just finds your template files for you.
89-
90-
We do this using one of two ways depending on how you've integrated Tailwind into your project:
91-
92-
- **Using the PostCSS plugin or the CLI**, Tailwind will crawl your entire project looking for template files, using a bunch of heuristics we've built in to keep things fast, like not crawling directories that are in your `.gitignore` file, and ignoring binary file formats.
93-
94-
- **Using the Vite plugin**, we rely on the module graph. This is amazing because we know exactly what files you're actually using, so it's maximally performant, and with no false positives or negatives. We're hoping to expand this approach outside of the Vite ecosystem with other bundler plugins in the future.
95-
96-
We'll introduce a way to configure content paths explicitly in the future for sure, but we're curious to see how well this automatic approach works for everyone — it's working awesome in our own projects.
97-
98-
---
99-
100-
## CSS-first configuration
101-
102-
A major goal of Tailwind CSS v4.0 is making the framework feel CSS-native, and less like a JavaScript library.
103-
104-
Once you've installed it, you add it to your project with a regular CSS `@import` statement:
105-
106-
```css {{ filename: 'main.css', style: 'framed', color: 'sky' }}
107-
@import "tailwindcss";
108-
109-
110-
```
111-
112-
And instead of setting up all of your customizations in a JavaScript configuration file, you just use CSS variables:
113-
114-
```css {{ filename: 'main.css', style: 'framed', color: 'purple' }}
115-
@import "tailwindcss";
116-
117-
@theme {
118-
--font-family-display: "Satoshi", "sans-serif";
119-
120-
--breakpoint-3xl: 1920px;
121-
122-
--color-neon-pink: oklch(71.7% 0.25 360);
123-
--color-neon-lime: oklch(91.5% 0.258 129);
124-
--color-neon-cyan: oklch(91.3% 0.139 195.8);
125-
}
126-
```
127-
128-
The special `@theme` directive tells Tailwind to make new utilities and variants available based on those variables, letting you use classes like `3xl:text-neon-lime` in your markup:
129-
130-
```html {{ filename: 'index.html', style: 'framed', color: 'pink' }}
131-
<div class="max-w-lg **3xl:max-w-xl**">
132-
<h1 class="**font-display** text-4xl">
133-
Data to <span class="**text-neon-cyan**">enrich</span> your online business
134-
</h1>
135-
</div>
136-
```
137-
138-
Adding new CSS variables behaves like `extend` did in earlier versions of the framework, but you can override a whole set of variables by clearing the namespace with syntax like `--color-*: initial` before defining all of your custom values:
139-
140-
```css {{ filename: 'main.css', style: 'framed', color: 'fuchsia' }}
141-
@import "tailwindcss";
142-
143-
@theme {
144-
--color-*: initial;
145-
146-
--color-gray-50: #f8fafc;
147-
--color-gray-100: #f1f5f9;
148-
--color-gray-200: #e2e8f0;
149-
/* ... */
150-
--color-green-800: #3f6212;
151-
--color-green-900: #365314;
152-
--color-green-950: #1a2e05;
153-
}
154-
```
155-
156-
We're still fine-tuning some of the naming conventions, but you can [explore the default theme on GitHub](https://github.com/tailwindlabs/tailwindcss/blob/next/packages/tailwindcss/theme.css) to see what's available to customize.
157-
158-
If you don't want to explicitly clear the default theme and would rather start from scratch, you can import `"tailwindcss/preflight"` and `"tailwindcss/utilities"` directly to skip importing the default theme:
159-
160-
```diff-css {{ filename: 'main.css', style: 'framed', color: 'indigo' }}
161-
- @import "tailwindcss";
162-
+ @import "tailwindcss/preflight" layer(base);
163-
+ @import "tailwindcss/utilities" layer(utilities);
164-
165-
@theme {
166-
- --color-*: initial;
167-
--color-gray-50: #f8fafc;
168-
--color-gray-100: #f1f5f9;
169-
--color-gray-200: #e2e8f0;
170-
/* ... */
171-
--color-green-800: #3f6212;
172-
--color-green-900: #365314;
173-
--color-green-950: #1a2e05;
174-
}
175-
```
176-
177-
We also make all of your theme values available as native CSS variables in your custom CSS:
178-
179-
```css {{ filename: 'dist/main.css', style: 'framed', color: 'sky' }}
180-
:root {
181-
--color-gray-50: #f8fafc;
182-
--color-gray-100: #f1f5f9;
183-
--color-gray-200: #e2e8f0;
184-
/* ... */
185-
--color-green-800: #3f6212;
186-
--color-green-900: #365314;
187-
--color-green-950: #1a2e05;
188-
}
189-
```
190-
191-
This makes it easy to reference any of your theme values in arbitrary values without needing the `theme()` function:
192-
193-
```html {{ filename: 'index.html', style: 'framed', color: 'pink' }}
194-
<div class="p-[calc(var(--spacing-6)-1px)]">
195-
<!-- ... -->
196-
</div>
197-
```
198-
199-
It also makes it possible to use your theme values when working with UI libraries like Framer Motion, without having to use the `resolveConfig()` function:
200-
201-
```jsx {{ filename: 'JSX', style: 'framed', color: 'fuchsia' }}
202-
import { motion } from "framer-motion"
203-
204-
export const MyComponent = () => (
205-
<motion.div
206-
initial={{ y: 'var(--spacing-8)' }}
207-
animate={{ y: 0 }}
208-
exit={{ y: 'var(--spacing-8)' }}
209-
>
210-
{children}
211-
</motion.div>
212-
)
213-
```
214-
215-
---
216-
217-
## What's changed
218-
219-
We don't take breaking changes lightly, but there are a few things we're doing differently in v4 so far that are worth sharing:
220-
221-
- **Removed deprecated utilities** — we've removed utilities we stopped documenting a long time ago like `text-opacity-*`, `flex-grow-*`, and `decoration-slice` in favor of their modern replacements like `text-{color}/*`, `grow-*`, and `box-decoration-slice`.
222-
- **PostCSS plugin and CLI are separate packages** — the main `tailwindcss` package doesn't include these anymore since not everyone needs them, instead they should be installed separately using `@tailwindcss/postcss` and `@tailwindcss/cli`.
223-
- **No default border color** — the `border` utility used to default to `gray-200`, but now it defaults to `currentColor` like the browser does. We made this change to make it harder to accidentally introduce a wrong gray into your project if you're using `zinc` or `slate` or something else as your main gray.
224-
- **Rings are 1px by default** — the `ring` utility used to be a 3px blue ring by default, now it's a 1px ring using `currentColor`. We find ourselves using the `ring-*` utilities as an alternative to borders in our projects, and using `outline-*` for focus rings, so we think making things consistent here is a helpful change.
225-
226-
There are a handful of other really low-level implementation detail changes that might surface in some way in your projects, but nothing deliberate like these changes. If you bump into anything surprising, let us know.
227-
228-
---
229-
230-
## Roadmap to v4.0
231-
232-
This new engine is a ground-up rewrite, and up until now we've been focused entirely on this reimagined developer experience using the new configuration approach.
233-
234-
**We put an enormous amount of value in backwards compatibility**, and that's where the bulk of the work lies before we can tag a stable v4.0 release later this year.
235-
236-
- **Support for JavaScript configuration files** — reintroducing compatibility with the classic `tailwind.config.js` file to make migrating to v4 easy.
237-
- **Explicit content path configuration** — making it possible to tell Tailwind exactly where your templates are when automatic content detection isn't good enough for your setup.
238-
- **Support for other dark modes** — right now we only support dark mode using media queries, and still need to reimplement the selector and variant strategies.
239-
- **Plugins and custom utilities** — we don't have support for plugins, or for writing custom utilities that automatically work with variants yet. Obviously we will make this work before a stable release.
240-
- **Prefix support** — there's no way to configure a prefix for your classes yet, but we'll bring it back for sure.
241-
- **Safelists and blocklists** — can't force Tailwind to generate certain classes or prevent it from generating other classes yet.
242-
- **Support for `important` configuration** — there's no way to make utilities all generate with `!important` right now, but we plan to implement it.
243-
- **Support for the `theme()` function** — this isn't needed for new projects because you can use `var()` now, but we'll implement it for backwards compatibility.
244-
- **Standalone CLI** — we haven't worked on a standalone CLI for the new engine yet, but will absolutely have it before the v4.0 release.
245-
246-
Aside from that, I'm sure we'll find a lot of bugs to fix, some exciting new CSS features to sneak in, and refine some of these new APIs that need some more polish before a proper release.
247-
248-
I don't want to make promises on a specific release timeline, but I'd personally love to mark v4.0 as stable before the summer holiday season kicks in.
249-
250-
251-
---
252-
253-
## Try out the alpha
254-
255-
We've tagged a couple alpha releases already, and you can start playing with it in your projects today.
256-
257-
If you're using the Tailwind CSS IntelliSense extension for VS Code, make sure you switch to the prerelease version from the extension page, and if you're using our Prettier plugin, make sure you install the latest version.
258-
259-
If you find an issue, please [let us know on GitHub](https://github.com/tailwindlabs/tailwindcss/issues/new/choose). We really want this thing to be bullet-proof before we tag a stable release and reporting any problems you find will help us a lot.
260-
261-
### Using Vite
262-
263-
Install the Tailwind CSS v4 alpha and our new Vite plugin:
264-
265-
```bash
266-
$ npm install tailwindcss@next @tailwindcss/vite@next
267-
```
268-
269-
Then add our plugin to your `vite.config.ts` file:
270-
271-
```ts {{ filename: 'vite.config.ts' }}
272-
import tailwindcss from '@tailwindcss/vite'
273-
import { defineConfig } from 'vite'
274-
275-
export default defineConfig({
276-
plugins: [tailwindcss()],
277-
})
278-
```
279-
280-
Finally, import Tailwind in your main CSS file:
281-
282-
```css {{ filename: 'app.css' }}
283-
@import "tailwindcss";
284-
```
285-
286-
### Using PostCSS
287-
288-
Install the Tailwind CSS v4 alpha and the separate PostCSS plugin package:
289-
290-
```bash
291-
$ npm install tailwindcss@next @tailwindcss/postcss@next
292-
```
293-
294-
Then add our plugin to your `postcss.config.js` file:
295-
296-
```js {{ filename: 'postcss.config.js' }}
297-
module.exports = {
298-
plugins: {
299-
'@tailwindcss/postcss': {}
300-
}
301-
}
302-
```
303-
304-
Finally, import Tailwind in your main CSS file:
305-
306-
```css {{ filename: 'app.css' }}
307-
@import "tailwindcss";
308-
```
309-
310-
### Using the CLI
311-
312-
Install the Tailwind CSS v4 alpha and the separate CLI package:
313-
314-
```bash
315-
$ npm install tailwindcss@next @tailwindcss/cli@next
316-
```
317-
318-
Next, import Tailwind in your main CSS file:
319-
320-
```css {{ filename: 'app.css' }}
321-
@import "tailwindcss";
322-
```
323-
324-
Finally, compile your CSS using the CLI tool:
325-
326-
```bash
327-
$ npx @tailwindcss/cli@next -i app.css -o dist/app.css
328-
```
34+
Start building and help us bullet-proof this thing for the stable release early in the new year.

0 commit comments

Comments
 (0)