190 points · by ssernikk · 2y ago · 164 comments
Not having to come up with names for CSS classes, no duplicated CSS code, no fighting conflicting classes, everything in one file, being able to visualize a component just by reading the code... it's a godsend. I'll never go back to SCSS unless work obliges me.
Vue 3 with <script setup lang="ts">, TailwindCSS and Vite. The way God intended.
> If you can suppress the urge to retch long enough to give it a chance, I really think you’ll wonder how you ever worked with CSS any other way.
Now I'm going to try it.
It goes against semantic web, the old css zen garden etc, with good markup I can style a page however I want.
However using tailwind, it’s the get shit done tool. It is ugly, it goes against good web design and everything I believe makes good web design but it works fantastically well in practice.
I dislike using tailwind, at the same time I will choose to use tailwind without hesitation as it makes up process a lot less friction and avoids selector conflicts.
As soon as you want theming you'll need to start naming stuff. And if you want that theming to support third-party CSS overrides, or need good CSS selector support, you're going to be back to needing to name classes again.
Not everyone needs that, and that's fine. But there are plenty of people working on products and in environments where the Tailwind way is not going to be the path of least friction.
I would actually say StoryBook, or the StoryBook pattern at least, has been a much greater boon on FE development over the last decade.
DaisyUI on top of Tailwind helps, but then you may as well use Bootstrap and get better component support.
Working on an app with a great deal of technical debt last year, moving to Tailwind made a world of difference in being able to restyle components without also breaking styles on distant parts of the app that nobody on the team realized were relying on the same styles.
"Naming things is hard" is still such a cop-out.
Mess is still mess even if you are making it through a framework.
In the end I'll be writing <PricingCard :price="product.price" /> anyway. All that Tailwind garbage will be nicely hidden inside the component.
Saying it's because naming a class is hard is BS.
Tailwind is primarily a way to do "css-in-js", except it's "css-in-html". It might not look nice on the eye but it's fucking easier to maintain, safer to remove, etc. As long as you have a way to create "components" you're fine.
> Coming up with css class names is not hard.
Yes, unless you work alone on your tiny 2 weeks old side project, it's fucking hard.
idiot edit: not React, Rust.
I haven't used Vue (any version) so this wouldn't be the place I'd normally chime in about Svelte. People seem to love Vue as well.
So if you're on the vue-wagon, skip svelte and wait until the next "The way God intended". If you're on svelte now, skip the next "The way God intended" and then after that, jump on the new wagon.
I was heavily into full-stack SSR frameworks + jQuery, then Angular and React came along and I was like "oh heaven, is this were we headed?", ignored both of those for years and finally found peace in the sacred words of Evan You.
Helper functions like createEl(tag, attributes, style, text) help...
I'm a huge fan of this major improvement to the framework.
For example to make a box with rounded corners and a top and bottom section, all you need is this intuitive one-liner:
<div class="mt-5 mb-8 first:mt-0 last:mb-0 relative overflow-hidden rounded-2xl"><div class="pt-2 bg-slate-800 shadow-lg group"><div class="flex text-slate-400 text-xs leading-6"><div class="flex-none text-sky-300 border-t border-b border-t-transparent border-b-sky-300 px-4 py-1 flex items-center">app.css</div><div class="flex-auto flex items-center bg-slate-700/50 border border-slate-500/30 rounded-tl"></div></div><div class="children:my-0 children:!shadow-none children:bg-transparent"><pre class="language-css"><code class="language-css"><span class="token atrule"><span class="token rule">@import</span> <span class="token string">"tailwindcss"</span><span class="token punctuation">;</span></span></code></pre></div></div><div class="pointer-events-none absolute inset-0 rounded-2xl dark:ring-1 dark:ring-white/10 dark:ring-inset" aria-hidden="true"></div></div>
<div class="bg-white rounded-2xl">
<div class="bg-blue-500">Top Section</div>
<div>Bottom Section</div>
</div>1. When you're working with this code, it's far easier to read with proper formatting and syntax highlighting. I know people take issue with the verbosity of tailwind, but anything will look awful if you remove formatting.
2. This is lacking an equivalent non-tailwind approach. If you can share the equivalent vanilla HTML/CSS (or pick your preferred framework), and then paste it here as an unformatted text blob, this might be a bit more fair.
3. I don't think it's fair to describe this as just a "box with rounded corners and a top and bottom section". That can be done with tailwind with less complexity/syntax, if that's truly all you want.
<main class="py-6 px-4 sm:p-6 md:py-10 md:px-8">
<div class="max-w-4xl mx-auto grid grid-cols-1 lg:max-w-5xl lg:gap-x-20 lg:grid-cols-2">
<div class="relative p-3 col-start-1 row-start-1 flex flex-col-reverse rounded-lg bg-gradient-to-t from-black/75 via-black/0 sm:bg-none sm:row-start-2 sm:p-0 lg:row-start-1">
<h1 class="mt-1 text-lg font-semibold text-white sm:text-slate-900 md:text-2xl dark:sm:text-white">Beach House in Collingwood</h1>
<p class="text-sm leading-4 font-medium text-white sm:text-slate-500 dark:sm:text-slate-400">Entire house</p>
</div>
<div class="grid gap-4 col-start-1 col-end-3 row-start-1 sm:mb-6 sm:grid-cols-4 lg:gap-6 lg:col-start-2 lg:row-end-6 lg:row-span-6 lg:mb-0">
<img src="/beach-house.jpg" alt="" class="w-full h-60 object-cover rounded-lg sm:h-52 sm:col-span-2 lg:col-span-full" loading="lazy">
<img src="/beach-house-interior-1.jpg" alt="" class="hidden w-full h-52 object-cover rounded-lg sm:block sm:col-span-2 md:col-span-1 lg:row-start-2 lg:col-span-2 lg:h-32" loading="lazy">
<img src="/beach-house-interior-2.jpg" alt="" class="hidden w-full h-52 object-cover rounded-lg md:block lg:row-start-2 lg:col-span-2 lg:h-32" loading="lazy">
</div>
<dl class="mt-4 text-xs font-medium flex items-center row-start-2 sm:mt-1 sm:row-start-3 md:mt-2.5 lg:row-start-2">
<dt class="sr-only">Reviews</dt>
<dd class="text-indigo-600 flex items-center dark:text-indigo-400">
<svg width="24" height="24" fill="none" aria-hidden="true" class="mr-1 stroke-current dark:stroke-indigo-500">
<path d="m12 5 2 5h5l-4 4 2.103 5L12 16l-5.103 3L9 14l-4-4h5l2-5Z" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
</svg>
<span>4.89 <span class="text-slate-400 font-normal">(128)</span></span>
</dd>
<dt class="sr-only">Location</dt>
<dd class="flex items-center">
<svg width="2" height="2" aria-hidden="true" fill="currentColor" class="mx-3 text-slate-300">
<circle cx="1" cy="1" r="1" />
</svg>
<svg width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="mr-1 text-slate-400 dark:text-slate-500" aria-hidden="true">
<path d="M18 11.034C18 14.897 12 19 12 19s-6-4.103-6-7.966C6 7.655 8.819 5 12 5s6 2.655 6 6.034Z" />
<path d="M14 11a2 2 0 1 1-4 0 2 2 0 0 1 4 0Z" />
</svg>
Collingwood, Ontario
</dd>
</dl>
<div class="mt-4 col-start-1 row-start-3 self-center sm:mt-0 sm:col-start-2 sm:row-start-2 sm:row-span-2 lg:mt-6 lg:col-start-1 lg:row-start-3 lg:row-end-4">
<button type="button" class="bg-indigo-600 text-white text-sm leading-6 font-medium py-2 px-3 rounded-lg">Check availability</button>
</div>
<p class="mt-4 text-sm leading-6 col-start-1 sm:col-span-2 lg:mt-6 lg:row-start-4 lg:col-span-1 dark:text-slate-400">
This sunny and spacious room is for those traveling light and looking for a comfy and cosy place to lay their head for a night or two. This beach house sits in a vibrant neighborhood littered with cafes, pubs, restaurants and supermarkets and is close to all the major attractions such as Edinburgh Castle and Arthur's Seat.
</p>
</div>
</main>I guess that depends. Compared to what?
Again, show me the equivalent widget implemented some other way and we can have a useful discussion.
Having spent a little time experimenting with tailwind for prototypes in the past, I can understand what that snippet is doing pretty easily. Having spent a lot more time writing vanilla HTML/CSS, I can immediately imagine all of the ways the vanilla version would be a nightmare, or at least take far longer to build “properly”.
Tailwind is a fascinating project because it seems to either make sense to people or it seems to deeply offend them. For whatever reason, I’m able to build things with tailwind after just a few hours of use that I could never accomplish from scratch (or with some popular CSS frameworks for that matter) after years of hacking on HTML/CSS.
15 minutes getting familiar with the class naming conventions makes all of this seem far less scary.
And it’s worth considering the variety of use cases a framework like this is useful for. Maintainability means very different things depending on context, team, and what kind of thing you’re building.
Inline styles and abusing divs. I suspect the next hotness will be nested tables again.
It was like extreme eye exercise with eyeballs popping out at the end of the work day.
Tailwind CSS is a write-only CSS cult at the moment. Cults take some time to die. After a decade, one will have dozens of "Why I quit using Tailwind" posts on HN. Back to vanilla CSS!
Now, if one wants to use a sane implementation of Atomic CSS, look at: https://open-props.style/. Jeez that is so much more readable and maintainable.
When you say “does this look maintainable”, what you should be saying is “does this look maintainable compared to this other thing”.
Z3 = function(a) { a = g.fb(a); delete X3[a]; g.md(X3) && Y3 && Y3.stop() },
...or maybe the build-output isn't a great indicator for maintainability. If you write your html directly like you posted above, it won't be maintainable regardless of how you structure your css./s?
The biggest problem with CSS when trying to maintain a design system is the same problems you run into any time you use inheritance in programming.
Inheritance has its place, but making your CSS composable the way Tailwind does makes it practical to actually adhere to a design system.
If you’re more worried about the purity of your HTML, then Tailwind is not for you.
In my front end, for example, I have registration-page.jsx and registration-page.less, and there is really zero mystery where the styles are for the registration-page. It uses components like password-input.jsx, and guess what? the CSS for that is in password-input.less. There's no grepping, there's no difficulty finding the classes that are specified. Everything is very orderly and easy to find.
On work projects with 5 years of contributions wrote by 50+ collaborators and close deadlines? Hardly think so.
Or use your IDE's project search? In vscode you can just ctrl-click on the class and it should find it?
IT IS NOT DIFFICULT
Ask me how I know!
<div class="custom-box"><div class="header"><div class="tab">app.css</div><div class="header-expand"></div></div><div class="content"><pre><code>@import "tailwindcss";</code></pre></div></div>
.custom-box {margin-top: 1.25rem; margin-bottom: 2rem; position: relative; overflow: hidden; border-radius: 0.5rem;}.custom-box:first-child {margin-top: 0;}.custom-box:last-child {margin-bottom: 0;}.header {padding-top: 0.5rem; background-color: #1E293B; box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); display: flex; color: #94A3B8; font-size: 0.75rem; line-height: 1.5;}.tab {flex: none; color: #0EA5E9; border-top: transparent; border-bottom: 2px solid #0EA5E9; padding: 0.25rem 1rem; display: flex; align-items: center;}.header-expand {flex-grow: 1; background-color: #334155/50; border: 1px solid rgba(156, 163, 175, 0.3); border-radius: 0.375rem 0 0 0;}.content pre, .content code {margin: 0; background: none; box-shadow: none;}@media (prefers-color-scheme: dark) {.custom-box::after {box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);}.header {background-color: #334155;}.tab {color: #bfdbfe;}.header-expand {background-color: #475569; border-color: rgba(255, 255, 255, 0.2);}}@media (min-width: 640px) {.custom-box {margin-top: 1.5rem; margin-bottom: 2.5rem;}.header {padding-top: 0.75rem;}.tab, .header-expand {padding: 0.5rem 1.25rem;}.content pre, .content code {font-size: 0.875rem;}}@media (min-width: 768px) {.custom-box {margin-top: 2rem; margin-bottom: 3rem;}.header {padding-top: 1rem;}.tab, .header-expand {padding: 0.75rem 1.5rem;}.content pre, .content code {font-size: 1rem;}}@media (min-width: 1024px) {.custom-box {margin-top: 2.5rem; margin-bottom: 3.5rem;}.header {padding-top: 1.25rem;}.tab, .header-expand {padding: 1rem 1.75rem;}.content pre, .content code {font-size: 1.125rem;}}@media (min-width: 1280px) {.custom-box {margin-top: 3rem; margin-bottom: 4rem;}.header {padding-top: 1.5rem;}.tab, .header-expand {padding: 1.25rem 2rem;}.content pre, .content code {font-size: 1.25rem;}}@media (min-width: 1536px) {.custom-box {margin-top: 3.5rem; margin-bottom: 4.5rem;}.header {padding-top: 1.75rem;}.tab, .header-expand {padding: 1.5rem 2.25rem;}.content pre, .content code {font-size: 1.375rem;}}.content > * {margin:0; box-shadow: none; background: transparent;}
(this probably an incomplete/buggy/incorrect port of Tailwind behavior)
Besides, I suspect (but not know, because my experience with tailwind is very minimal) that that output is readable and understandable by those experienced and developing with tailwind. On top of all the other affordances modern dev tools gives to understand styling on elements (esp. the computed pane)
This part is the most exciting to me. Given the rest of the release announcement, I'm assuming this means that it'll be built in Rust rather than embed Node. While I'm not a Rust zealot of anything, I'm very partial to not embedding Node. Particularly when it depends on using Vercel's now-abandoned pkg[1] tool.
But I strongly agree.
I've been working with a fully Rust-based web stack, and it's been such a joy. Tailwind compilation causes me to still deal with Node. I'd love to see that go away.
.vertical-center-line {
background: linear-gradient(#000, #000) no-repeat center/2px 100%;
}
.horizontal-left-center-line {
background: linear-gradient(to right, #000, #000) no-repeat left/50% 2px;
}
.horizontal-right-center-line {
background: linear-gradient(to right, #000, #000) no-repeat right/50% 2px;
}It took years to just convince them of the need for it. And I'm not sure anyone got convinced vs Chrome had already shipped it and Safari has it planned so they caved in. The most recent update I'm aware of is that it's "worth prototyping".
Hard to believe FireFox used to be a leader of the modern web.
In 2026, sure! Go nuts and rip it all out, but give people a bit to update first unless your target market is SF tech influencers.
My general take of the overall quality is that the maintainers of Tailwind have really good intuition in terms of what to prioritize, as well as excellent design taste. Tailwind is one of those tools where it only makes sense once you start to use it, but each version they've announced brings a continuously more polished product.
If you don't like Tailwind or you don't understand it or if anything I'm saying makes you mad, try first building something big with it. It's pretty maintainable, easy to read and write, and, most of all, is very portable. (I mean that in the sense that something you write in one place can be copy and pasted somewhere else and it will more than likely work exactly the same.)
As far as this version is concerned, it looks like not a whole lot has changed from a compatibility perspective, but I think when version 4 becomes official it might have more breaking changes. In any case, the prospect of a new engine is very cool, as faster builds are always welcome.
Congratulations to the team! I may not be a front end engineer, but with Tailwind I don't really have to be to make what I want.
> something you write in one place can be copy and pasted somewhere else
That sounds like the opposite of maintainable.
However, a traditional class-based, modular approach to CSS can not guarantee portability in the same way. So if you can not predict what effect the same classes, or even the exact same HTML, will have, then it's neither portable nor is it very maintainable either.
FWIW, for the app I’m working on currently, I’m outsourcing most of my styles to Bootstrap, while pushing hard for progressive enhancement via CSS hacks (for effects like expanding/collapsing menus and switching tabs). I’m using htmx when JS is enabled, and regular HTTP for when it’s disabled (the Django back-end renders partial or full pages based on request type). Bootstrap and htmx don’t really step on each other’s toes, and I don’t see why htmx + Tailwind to be different.
If in doubt, experiment!
For us, one big benefit of using Tailwind has been that we can avoid spending a lot of time thinking about CSS and CSS tooling, and being able to configure everything via JS has helped in that regard.
<a bg="red" text="white" dark="bg:red text:white">link</a>With that aside, the blog post mentions not having to use `postcss-import` but it seems to include that as dependency. So we're still using `postcss-import`.
Here's an example from my main work app:
Components: https://github.com/oxidecomputer/console/blob/da07ce01a8fb7f...
Clean call site: https://github.com/oxidecomputer/console/blob/da07ce01a8fb7f...
But what is the point of introducing a directive called "@theme{}" though for configuration?
Why not just do ":root{}"?
Best of luck and thanks for driving progress forward with the project still.
> We also make all of your theme values available as native CSS variables in your custom CSS
theme() makes using them more tailwind-y
For optimal gzipping (and saner readability) it's recommended to have sorted classes (prettier-plugin-tailwindcss)
But if you want to have some overridability (avoid clashing of p-4 and p-8) you need tailwind-merge.
These two don't play together well
Button.css
I find it's often easier/cleaner to just pop a CSS file in for some of these foundational components that have tons of variations. Can use nested CSS now, and the selectors are easier to to work with IMHO and take care of specificity.I had hopes with google in this as they already likely have things like official docs, updation etc labelled so they can give different weights to every document. But then there is Gemini.
Here's a good primer on it: https://aws.amazon.com/what-is/retrieval-augmented-generatio...
And here's a recent HN thread about RAG on PostgreSQL: https://news.ycombinator.com/item?id=39613669
Wow, a CSS library with a developer event and Apple style keynotes.
I wanted to love it, but instead got bogged down in all this PostCSS nonsense and configuration before I could do anything.
Happy to see they're moving towards a "it just works out of the box" approach.