Home >Web Front-end >CSS Tutorial >Exciting updates in Tailwind v�

Exciting updates in Tailwind v�

Susan Sarandon
Susan SarandonOriginal
2024-12-08 13:48:11413browse

Several months ago (at the time of writing), Tailwind CSS open-sourced its work on Tailwind CSS v4.0. (You can find it on GitHub here).

Recently, Tailwind announced a public beta for Tailwind CSS 4, and in this article I'll cover the highlights of the new version. So let's get started!

General Structure Changes

Tailwind has undergone a rework of its engine that drastically improves performance. Full builds are up to 5x faster, incremental builds up to 100x (you read that right) faster.

Tailwind v4 also has a unified toolchain. Remember having to install autoprefixer and postcss in all of your Tailwind projects? You won't have to anymore!

Taking an interesting approach to configuration, Tailwind is moving from JS config files to CSS config. This means you will configure plugins, themes, and other behavior directly in your CSS.

Tailwind is also getting support for the latest features in CSS.

Exciting updates in Tailwind v�

CSS has a new logo (and new features)! ?

Best Codes ・ Nov 23

#css #webdev #programming #discuss

Now, with the general changes out the way, let's see what specifically Tailwind is adding!


New Features ?

If you want to try Tailwind v4, view the getting started docs for v4 (beta).

If you want to easily upgrade your project, just run npx @tailwindcss/upgrade@next and Tailwind will do it for you. Be careful! There may be breaking changes.

Colors

The Tailwind v4 color palette is based on oklch instead of rgb. The RGB color system is a bit limiting in terms of consistency across screens and vibrancy. Since the oklch color system is now widely supported, Tailwind v4 is going to take advantage of it!

Exciting updates in Tailwind v�

Container queries

Tailwind v4 now supports container queries by default. If you don't know what container queries are, let me explain.

You know things in Tailwind like md:, sm:, etc. that allow you to customize what CSS is applied on different screen sizes?
In those cases, the classes refer to the size of a window. With container queries, they can refer to the size of a container instead.

<div>



<p>In the above example, the grid will have 3 columns — not when the <em>window</em> reaches the small size, but when the <em>container</em> does. As you can imagine, this is super handy in responsive layouts.</p>

<h2>
  
  
  Field sizing
</h2>

<p>field-sizing isn't a universally supported CSS feature yet, but it's going to be awesome when it is! Instead of needing JS to create auto-resizing textareas, you can use CSS only.<br>
And Tailwind v4 supports it!</p>

<p>Try out the demo on Tailwind's website.<br>
You can now simply add the field-sizing-content class to your textarea to use it.</p>
<h2>
  
  
  Descendant updates
</h2>

<p>Tailwind stable (you may not know this) has an * variant that allows you to target <em>direct</em> children of an element with a class. For example:<br>
</p>

<pre class="brush:php;toolbar:false"><div>



<p>The new ** variant in Tailwind v4 will target <em>all descendants</em>:<br>
</p>

<pre class="brush:php;toolbar:false"><div>



<h2>
  
  
  Inset shadows (and rings)
</h2>

<p>It will also now be easy to create inset shadows and rings on elements using the inset-shadow and inset-ring classes.<br>
</p>

<pre class="brush:php;toolbar:false"><button>



<p><img src="https://img.php.cn/upload/article/000/000/000/173363689867865.jpg" alt="Exciting updates in Tailwind v�"></p>


<hr>

<h2>
  
  
  There's much more!
</h2>

<p>If you want to see all the new additions, go to https://tailwindcss.com/docs/v4-beta and check them out!</p><p>This post is a #discuss post! That's why I kept it short; I want to know what you think!<br>
I know a lot of you Tailwind haters will probably have some feedback for me ?<br>
There are definitely some controversial new features and I want to get some opinions ?</p>

<p>Summary: Leave a comment!</p>


<hr>

<p>Thanks for reading!<br>
BestCodes</p>


          

            
        

The above is the detailed content of Exciting updates in Tailwind v�. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn