DEV Community 👩‍💻👨‍💻

Cover image for Tailwind isn't the answer
Madi Ostoja
Madi Ostoja

Posted on • Updated on

Tailwind isn't the answer

Tailwind CSS has taken the frontend development world by storm over the last few years. A utility-first library of CSS classes, it promises a new way of styling that's more consistent, maintainable, and faster than writing CSS directly. And for the most part, it delivers on that promise.

By using Tailwind you're almost guaranteed a single source of truth for all the values you use throughout a project. From typesets to spacing to colours, everything is defined in a single place. Which means that your code stays consistent and you aren't making things up as you go.

This was Tailwind's biggest idea, and the greatest benefit of utility-first CSS as a concept: compose don't create.

Tailwind achieves this with an extensive library of CSS classes to style everything. The idea being that you no longer write any CSS of your own, you compose predefined classes like lego pieces for every single property.

Developers new to this way of working often have a knee-jerk reaction just from looking at example code.

<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
 Button
</button>
Enter fullscreen mode Exit fullscreen mode

There's no denying that Tailwind is hideous. Its creator acknowledges as much right on the project home page. But that's just pedantry, and if the Tailwind way of doing things really was the panacea to all our problems then it would be a very small price to pay.

The Problem

The problem with this approach isn't that its ugly, or bloated (Tailwind purges unused classes), or that "you might as well write inline styles" (you shouldn't). It's that in order to apply a consistent set of values with classes, you also have to create classes for every conceivable set of rule:value pairs in CSS, even where it adds no value at all. So you end up using classes like .block rather than writing display: block and .text-center rather than text-align: center.

Of course you can mix Tailwind's more useful classes with regular CSS. But then you're breaking the Tailwind style-by-classes abstraction, and you have to maintain two seperate styling touchpoints for every element.

"So what?" you might ask, what's wrong with just using those classes rather than CSS? It certainly saves some keystrokes. Here is where Tailwind introduces new problems it shouldn't have to solve in the first place.

Reinventing CSS

Tailwind has to reinvent everything regular CSS can already do. Media queries, pseudo elements, selectors, and states. All of it now has to fit into the classes-only paradigm.

Tailwind achieves this with what it calls modifiers. By prepending Tailwind classes with md: they will only apply above the md breakpoint. By appending hover: a class will be applied in a :hover state. And so on.

Each of these tools is a poor facsimile of the functionality gaps it has to fill. Want an :nth-child or ~ sibling selector? Back to CSS. Want to target the devices between two breakpoints? Back to CSS. Want to target children of an element? Back to CSS. You get the picture.

Of course you can go back to CSS to do any of these things. Lovingly coined "bailwind", almost every project will need at least a little custom CSS when Taiwind's classes and modifiers just don't cut it. But then you're back at breaking the Tailwind abstraction, and giving yourself maintenance headaches.

And if this is already a given, then why use pointless classes like block when it adds no consistency or maintainability value over writing display: block in CSS, other than a few saved keystrokes? Because while gap-filling classes like this don't add value, they do add a new Domain Specific Language (DSL) to learn on top of the CSS we all already know.

Class soup

The thing every critic of Tailwind yells at first, its enormous class strings. Yes, they're ugly, but who cares. The problem isn't a surface-level developer perfectionism one. It again comes back to modifiers.

Every rule that applies to a modified state needs its own class with its own modifier. Unlike in CSS where these states and pseudo elements are naturally organised into logical blocks, Tailwind's modified classes can very quickly become a huge, difficult to maintain mess that has to be carefully teased apart line by line.

Take a contrived example of the button we had in the intro of this article, with an icon of some sort added to a ::before pseudo element, and less-than-ideal attention given to class ordering.

<button class="relative before:absolute bg-blue-500 hover:bg-blue-700 text-white before:left-2 font-bold before:text-sm py-2 px-6 rounded  before:top-1/2 before:content-['\f00c']  before:-translate-y-1/2">
  Button with icon
</button>
Enter fullscreen mode Exit fullscreen mode

Of course in this particular example the icon would be better placed as a real element inside the button, but the point stands. Without (and even with) careful ordering of classes, these jumbles very quickly become a maintenance nightmare.

JIT to the rescue?

Tailwind's new Just In Time mode compiles just the classes you use on the fly, rather than pruning back a goliathan stylesheet after the fact. It allows you to use modifiers everywhere out of the box, and most importantly write arbitrary values right in Tailwind classes, like margin-[100px].

This is another language feature that was added to Tailwind's style-by-classes DSL in order to fix problems it introduced itself. And while arbitrary values mean you don't have to break out of Tailwind's paradigm as often, they also diminish the core value that Tailwind provides — a single source of truth for a whole project. Taken to its logical extreme Tailwind JIT is really just reinventing CSS, bit by bit.

The Solution

As I said at the very beginning, Tailwinds' central idea is a very good one — a low-level, utility-driven design system to get rid of magic numbers and bring consistency to your CSS. The problem was the implementation.

Thankfully CSS now has the same solution as every other language to consistent values: variables. CSS variables, or more properly CSS custom properties, are fairly new to the language but already adopted by every major browser, and used extensively in Tailwind's own internals.

For example, Tailwind's .p-4 padding utility could be rewritten like this

:root {
--p-4: 16px;
}

.button {
  padding: var(--p-4);
}
Enter fullscreen mode Exit fullscreen mode

And since we no longer have to write separate classes for every rule:value pair, we can greatly simplify our utility-first design system. We could have one set of size variables that can be applied to any part of padding, margin, width, height, position, etc. Without needing separate utilities for every combination of every property.

:root {
  --size-2: 8px;
  --size-4: 16px;
}

.button {
  padding: var(--size-2) var(--size-4);
  margin: var(--size-4) 0;
}
Enter fullscreen mode Exit fullscreen mode

And since variables are part of the platform, they have a native runtime. We can interact with CSS variables using Javascript, and update them dynamically. This makes things like reskinning a whole interface for dark mode possible with just a couple lines of code, without introducing any new utilities or tools.

function enableDarkMode() {
  document.documentElement.style.setProperty(`--color-background`, `black`);
  document.documentElement.style.setProperty(`--color-text`, `white`);
}
Enter fullscreen mode Exit fullscreen mode

So why don't we, instead of reinventing the styling paradigm altogether, just abstract all the values in an interface into a single source of truth by putting them in CSS variables that can be used anywhere, in regular old CSS, without all these new problems?

By Example

GitHub logo peppercornstudio / pollen

Utility-first CSS for the future

Pollen


Pollen

Utility-first CSS for the future

Introduction

Version Size

Pollen is a standards-driven alternative to Tailwind. A micro-library of CSS variables, it encourages consistency, maintainability, and rapid development. Use it from prototype to production, as a utility-first foundation for your own design system.

What it looks like

Pollen's low-level variables can be used to build any design. They work anywhere and don't require a buildstep or class naming conventions. They're easy to extend and globally responsive, without introducing preprocessors or new syntax.

.button {
  font-size: var(--scale-00);
  font-weight: var(--font-medium);
  padding: var(--size-2) var(--size-3);
  background: var(--color-blue);
  border-radius: var(--radius-sm);
  box-shadow: var(--elevation-2);
  color: white;
}
Enter fullscreen mode Exit fullscreen mode

Documentation

Read the full documentation at pollen.style

Pollen is a standards-driven CSS library that came from this line of thinking. It takes Tailwind’s core ideas and reimplements them as a 0.85kb collection of plain CSS variables. It can deliver all the key benefits of Tailwind without reinventing how we write CSS, thanks to the tools we already have in the web platform. Since it’s just plain CSS it can be used anywhere in any context and in any way.

But you might not need it

Full disclosure: I wrote Pollen. But I'm not trying to sell you on adopting it. I'm trying to sell you on the ideas behind it for your own work.

Pollen is just a collection of hopefully useful CSS variables, translated from Tailwind. But If you already have a solid design system with sizes, typesets, colours, and the other shared values of an interface, then you probably don't need Pollen, and you certainly don't need Tailwind. Write them in one place as CSS variables, and use them everywhere. That's the way out of this insanity.

Bring consistency to CSS by getting rid of magic numbers with variables. The other problems of CSS (deep composition, leaky inheritance, performance optimisation) aren't solved by Tailwind, nor by CSS variables. But they are made harder by the new DSL Tailwind introduces. At least by sticking to regular CSS you have all the other patterns and tools we as a community have been working on for the last decade at your disposal, without any gotchas.

Top comments (113)

The discussion has been locked. New comments can't be added.
Comments have gotten pretty spicy, and I don't think much valuable discussion is happening any more. See my comment for reiteration on some of the concerns raised.
Collapse
 
gangsthub profile image
Paul Melero

Once again, if you don't like X technology, don't use it. But you don't need to look down on it. If you've created a library with a new paradigm, why not focusing more on the possitive side of it?

Collapse
 
madeleineostoja profile image
Madi Ostoja Author • Edited on

I literally opened the article praising Tailwind’s core ideas, and how it solves some real problems. But I also think it has some real issues that many people might not consider until they’re maintaining projects at scale with it. If Tailwind fits your use case then go for it, it’s a solid library by some clever people

Collapse
 
lumsdendigital profile image
Ruaidhri Lumsden

Well said Madi. Thanks for the article, I'll certainly keep this on my reading list in case I do come up against your started issues.

Personally, so far, I love using Tailwind. I just find being able to do my CSS within my markup to be great for productivity, but doesn't feel like 'cheating' because I feel like I still have to understand all of the CSS that it's applying.

I also don't mind having to break out of the abstraction to do some custom CSS in specific cases - for me I don't particularly mind having a long list of utilities such as mt-3, border-2 etc - if it keeps that basic stuff from creating one or, perhaps multiple, large CSS files. It keeps what is in the custom CSS more focused.

Like I said, I haven't really felt like it's limited me so far, but I'll keep this post in mind if I ever feel like it does!

Collapse
 
sgarciadev profile image
Sergei Garcia • Edited on

Because attacking the leading competitor is the easiest way to pitch something new. Conveniently enough, the author left out any any mention of cons & issues Pollen has over Tailwind. Or how it reintroduces decades old issues traditional CSS codebases have dealing with writing semantic CSS class names, organizing CSS, and handling specificity issues.

But yeah, this was a weird, if not cheap way to introduce Pollen.

Collapse
 
madeleineostoja profile image
Madi Ostoja Author • Edited on

Hey I really don’t know why you have this axe to grind. For a start nothing about using CSS variables implies needing semantic CSS class names, how you should organise CSS, or deal with specificity. There are so many solutions out there for all of those issues, and variables work in all of them. It is literally just CSS.

And as I have said maaany times, you absolutely don’t need to use Pollen, it isn’t some crazy new framework. It’s literally a collection of CSS variables. If you find it useful then awesome, but what I’m trying to get across is that the platform already has a solution to the value tailwind provides, and the style-by-classes abstraction introduces a lot of difficult problems that often don’t become apparent until you’re using it at scale.

Sorry you didn’t find it helpful.

 
sgarciadev profile image
Sergei Garcia • Edited on

You can't expect people to not elaborate on the important details you omitted.

For a start nothing about using CSS variables implies needing semantic CSS class names, how you should organise CSS, or deal with specificity. There are so many solutions out there for all of those issues, and variables work in all of them. It is literally just CSS.

Using CSS variables might not imply it, but moving away from a utility-first CSS paradigm like Tailwind's absolutely implies you now need to worry about that. Yes, there are many "solutions" to these issues, but they are far from a silver bullet that magically makes all problems go away. Writing semantic CSS class names will still be hard, CSS code duplication will still be a challenge, and you'll still need to come up with a strategy for avoiding CSS specificity issues. Not to mention you now have to factor in the decision making towards how you will solve each problem. And like you said before, a lot of this also doesn't become apparent "until you're using it at scale". And yet, you don't acknowledge any of this in your article.

you absolutely don’t need to use Pollen, it isn’t some crazy new framework.

Then perhaps don't write an article title and pitch that sounds like you're created this crazy new framework that solves all of Tailwind's issues?

what I’m trying to get across is that the platform already has a solution to the value tailwind provides, and the style-by-classes abstraction introduces a lot of difficult problems that often don’t become apparent until you’re using it at scale.

Great. But you're not doing a very good job at this by omitting pros and cons from both sides. And no, praising Tailwind at the start of the article isn't quite what I mean. I know you had fair reasons to omit a lot of information and important considerations when choosing Pollen over Tailwind (since you clearly have experience with Tailwind) such as that a lot of things should be "obvious" to people that have used Tailwind. However, not everyone reading this has used Tailwind in the past. And all you end up doing is spreading missinformation for the sake of pitching your new library.

 
joshuaamaju profile image
Joshua Amaju • Edited on

Tailwind fan boy right?

 
sgarciadev profile image
Sergei Garcia

Nope, just someone who prefers conversations stay neutral and unbiased.

Though calling someone a fan boy just because you disagree with them instead of providing valid counter-arguments could be considered immature and I'd advice against it if I were you.

 
zafaralam profile image
Zafar Alam

Sorry to say this Sergei, but your whole comment is biased towards tailwind.

I think the author is merely providing his opinion on a technology and proving an alternative approch to people new/existing to the CSS landscape and are looking for solutions.

If you disagree with the author's opinion then don't worry about it and keep doing what works for you and that is okay!

 
joshuaamaju profile image
Joshua Amaju

You literally went crazy about someone criticising tailwind. It's difficult to reason with people at that point, so fan boy would do.

 
sgarciadev profile image
Sergei Garcia

So if the author conveniently omitted important key information from the comparison it's called "providing her opinion". But when I include the details she omitted, it's called "biased"? Something tells me people now throw around the term "biased" too lightly nowadays just to describe any time they dislike it's content.

I think the author is merely providing his opinion on a technology and proving an alternative approch to people new/existing to the CSS landscape and are looking for solutions.

The author provided his opinion in a biased way by omitting key information when it suited their pitch for a new library, I'm not sure how anyone here is missing it. And by omitting information, it does nothing but spread missinformation to people new/existing in the CSS landscape about Tailwind and it's alternatives.

I'm aware Tailwind is not a silver bullet either and it absolutely has it's downsides. However, for the comparison to be fair, it needs to include all valid pros and cons from both sides, not just the ones that suit the author writing it.

Collapse
 
nickfotopoulos profile image
Nick Fotopoulos

Madi only stated what everyone who uses Tailwind already knew. Also, the comparison was necessary as Pollen was "inspired by Tailwind".

Collapse
 
justindmyers profile image
Justin Myers

It's LITERALLY the concept of Design Token.

Pollen has absolutely nothing to do with Tailwind. She's using Tailwind to get attention to her framework, nothing more.

Collapse
 
devwillis profile image
David Willis

Nothing can ever be improved if it's not okay to think critically.

Collapse
 
hellojere profile image
Jere Salonen

If you don't like X article, don't read it. But you don't need to look down on it. If you've learned a library with a paradigm, why not focusing more on writing about the positive sides of it?

^such a narrow-minded approach to anything in life.

Collapse
 
joshuaamaju profile image
Joshua Amaju

The metaphorical snake eating its own tail

Collapse
 
andersbjorkland profile image
Anders Björkland

How can you write something so compelling when I've put so much effort to get semi-comfortable with Tailwind?! 😉

It's often so long between the projects where I use Tailwind that I'm constantly on their docs (they are great by the way). But it's adding an extra step for me. I know how to do something in CSS but I'm using the docs to find what the utility class is for what I want to do. I've been most happy styling when I've used SASS modules. But it's no denying that regular CSS variables are greatly appreciated!

Thanks for the write-up! I'm gonna stare into the mirror for a bit and see if I'll just yeet a dependency where regular CSS makes more sense 🤔

Collapse
 
terworth profile image
Pascal • Edited on

Yo! Stop shitting all over the comment section folks. As some of you said, if you don't like it, don't use it. Stop taking place for a framework as if it was a person. IT'S A TOOL. And as it is with tools, new ones come out, new ones will be similar to old ones and some will be more or less effective. It's all about what you need to do. Just then you should think of how to do it. And in times like these where everything is overly complicated, there's no place to say no to something that's trying to make our life just a little better. If you think this post/framework is valid, great! If not, why even bother?
I myself love tailwind and won't stop doing so, because It does most things better than most if not any other framework I've used before (And I tried most already). I will consider Pollen too though. I love CSS variables since they came out, and if Pollen makes sense in that regard, there could be projects where it would make sense to use it. I love new tools. And you should too. 🤓 And Pollen and Tailwind kinda share the same principles and ideas anyways. Less is more.

Collapse
 
madeleineostoja profile image
Madi Ostoja Author

Thank you 😌

I really didn’t mean to start a flame war. Tailwind is a solid framework written by some very smart people. I think it introduces some problems, especially at scale, but if it makes sense for someone’s use case then awesome!

Collapse
 
joelbonetr profile image
JoelBonetR

I completely agree, I would say more: Tailwind never was a solution.
Using Sass modules properly gives you the same source of truth and theming capabilities without messing with the structure on a much more maintainable way.

For me, Tailwind is so absurd that you need to learn the entire CSS API in a wrong way that makes you able to work only with tailwind projects while learning the proper standard API from CSS and the capabilities of Sass leads you to a top tier front end dev.

The refactors when using tailwind due to re-designs are just hilarious and I bet it will die before it reaches the successful status as a tech. That and the bloatware in the structure are the main reasons for which it will probably die sooner than later. Imagine having to edit like 300 html elements changing some classes to another ones just to fit the new design. I'll leave in a blink 😆

For reference, currently there's only 1 job available on LinkedIn that mentions "Tailwind".

Collapse
 
sgarciadev profile image
Sergei Garcia

Using Sass modules properly gives you the same source of truth and theming capabilities without messing with the structure on a much more maintainable way.

"much more maintainable" is debatable. Since CSS class name organization has been a staple issue for decades, something Tailwind does away with. Your HTML may be less messy, sure, but you are moving the organization problem to your CSS files where it can become an even worse nightmare.

Imagine having to edit like 300 html elements changing some classes to another ones just to fit the new design.

Tailwind doesn't do away with reusable classes, they still allow them in the shape of components. And should you be building a SPA with React, Angular or Vue, you would simply change that component affected. If you need to update "300 elements" for even a small design change, you aren't using Tailwind correctly.

Then again, I don't blame you for thinking this. I had the same reaction as you the first time I learned about Tailwind CSS. And only after seeing it in action in a production project did I finally start to understand its benefits.

Collapse
 
joelbonetr profile image
JoelBonetR

Along with a SPA library like React or a framework like Angular, Next or Vue I use CSS modules with a good architecture on it.
There's a theme.scss that exports the color-related stuff, a grid.scss that does the obvious and a global.scss that exports utilities and similar stuff. All the color-related stuff is declared inside theme (this allows for a quick reaction to design color changes) and what belongs to each component is inside the component directory as component.module.scss

it's just a matter of good architecture and experience. Of course if the devs are generating dummy classnames constantly it will be a mess but there's a nonsense on comparing the worse use cases as there's no tech to deal with that.

Of course you can shape reusable components in tailwind and tailwind at all can be fine till it's not, and the "till it's not" happen when there's a refactor needed due to a redesign, it increases the chances for something to go wrong with design context (the same component looking different depending on the page it's shown).

My opinion is on the main hand due to an analysis and POC did 2 months ago comparing tools for a changes proof code, long story short: custom implementation using Scss inside Next.

Also the team having experience on that is a keystone but also the tech community and similar projects that applies it. As I've said, 1 job available with the keyword "Tailwind", there's a dark future for it in my opinion; just good for people that hate CSS so they learn it the bad way, the same when you add chicken with the vegetables to a kid so he don't cry 😆

 
sgarciadev profile image
Sergei Garcia • Edited on

My opinion is on the main hand due to an analysis and POC did 2 months ago comparing tools for a changes proof code, long story short: custom implementation using Scss inside Next.

Bingo. A POC is often not enough to get a good enough idea of something. And like I said before, I don't blame you for feeling this way. It's absolutely a big change in terms of paradigm. And people, by nature, fear change (sometimes irrationally). Many things we take for granted today as "the best practice" took generations to receive widespread adoption. Only time will tell if this is another of those moments.

1 job available with the keyword "Tailwind", there's a dark future for it in my opinion

If anything, this is a terrible way to gauge a product's viability. All major libraries started this way. And if the State of CSS global survey teaches us anything, is that Tailwind is quite new, and yet is having exceedingly high adoption numbers thanks to it's record-high user satisfaction and interest to learn it. I guess we'll find out in the coming weeks once the State of CSS 2021 survey comes out to see how much Tailwind has grown in 2021.

Collapse
 
kozakrisz profile image
Krisztian Kecskes

It is a good article. It is sad some fan boy try to resolve their soul and ego problems here in the comment section. You should write more article and don't worry about these kind of people. Keep it up! Your photos are awesome btw :-)

Collapse
 
madeleineostoja profile image
Madi Ostoja Author

Thank you so much!

Collapse
 
jackmellis profile image
Jack

Ah another week another "I don't like tailwind because" article. There are a few valid points but after about 18 months of using tailwind in several projects, I can say I'd find it pretty frustrating to go back to css or css-in-js again. Tailwind just makes styling fast and easy.

If anything, the verbosity of tailwind's class combinations works perfectly with view frameworks (React/Vue/Angular/etc) to abstract your styled elements into semantic components.

Anyway I'm not here to try and convince you to like tailwind. Some people love it, some people hate it. That's fine. Unless you're joining a new team where they use it extensively and you have to just suck it up and get on with, I suppose 😂

Collapse
 
madeleineostoja profile image
Madi Ostoja Author

That’s totally fair! I won’t deny tailwind helps speed up prototyping etc, and it’s not so much “I don’t like because X”, it’s that after using it in my new team where we do use it extensively, there are a bunch of issues that a lot of people might not realise until they’re at scale. Like it’s not that tailwind is some horrible stupid framework, I spend the first chunk of the article praising its ideas. It just has limitations to be aware of, which I think have better solutions in CSS. But if it works for you then awesome, it’s a solid library.

And for everything that is coming for my throat saying I didn’t present a balanced argument, I mean, the article was already huge, and look at the hype around tailwind presenting it as the panacea for our problems and a new way to style things. Tailwinds own rhetoric certainly doesn’t mention any limitations 🤷🏻‍♀️

Collapse
 
ortonomy profile image
🅖🅡🅔🅖🅞🅡🅨 🅞🅡🅣🅞🅝

YES! This guy gets it

Collapse
 
jeroka profile image
Esteban Rocha • Edited on

Software engineering is full of narrow-minded people who can't stand a critique.

Thanks to the people that dare to critique the status quo is why we can advance, I personally always felt like Tailwind will become the next Bootstrap, it's popularity is incredible as allows people who don't know CSS to ship.

Nevertheless I have use it and I understand it works in some scenarios, but I also prefer to use a similar approach by using the incredible tooling, APIs and new specs that CSS has, thanks for the article @madeleineostoja

Collapse
 
justindmyers profile image
Justin Myers

Because naming is literally one of the hardest problems in development? Why do you need a name in the first place?

Also, Tailwind still allows you to use your own names with @apply.

Does no one actually read the Tailwind docs before trying to shit on the framework?

Collapse
 
madeleineostoja profile image
Madi Ostoja Author

Tailwind isn’t the only way not to name things. I use css-in-js myself and much prefer that way of doing things, but that’s neither here nor there.

And yes I’ve used tailwind extensively and read all their docs. I seem to have really upset you I’m sorry if the article came across the wrong way

Collapse
 
hectorromo profile image
Hector Romo • Edited on

For all who thinks this is a way to sell in Pollen, read the article:

Full disclosure: I wrote Pollen. But I'm not trying to sell you on adopting it. I'm trying to sell you on the ideas behind it for your own work.

Good points and valid arguments in my point of view.

Collapse
 
royz profile image
Rajorshi Roy • Edited on

I just created an account here just to tell you how much I love this article. I agree with almost everything you said and I had most of these thoughts ever since I first tried tailwind. It blows my mind how every youtuber praises tailwind without mentioning the downsides.

Edit: I have nothing against tailwind. I just believe you should be aware of both good and bad sides of a framework/library/tool before you dive into a large project.

Collapse
 
madeleineostoja profile image
Madi Ostoja Author

I’m so glad you found it helpful!

Collapse
 
andersbjorkland profile image
Anders Björkland

No, I think the post raised some valid points. Sure, it's good knowing such a popular tool as Tailwind because I encounter it in other projects. But for myself, it doesn't really speed up my development and SASS modules are a good way to manage my styles, making it easy to maintain over time.

Still, I like what Tailwind has done for me. I started using it at a time when I had terrible style structure. It was a horrible jungle in style.css. Tailwind was a gust of fresh air and made my styles a bit more maintainable in comparison.

Collapse
 
brittonwalker profile image
Britton Walker • Edited on

Not being into Tailwind is totally valid. Using CSS variables is totally valid. I like to use Tailwind using @apply while creating BEM classes. I find it extremely useful, fast and easy to read doing something like:

.card {
  @apply py-1 lg:py-2 lg:flex lg:justify-between lg:items-center;
  &__title {
    @apply text-gray text-sm lg:text-lg;
  }
}
Enter fullscreen mode Exit fullscreen mode

It's become more of a property generator for me if that makes sense. It's really the variants and extendability that shine along with the new JIT.

Collapse
 
joshuaamaju profile image
Joshua Amaju

At that point why not just write css. I can probably consider the media queries part. But py-1, come on.

Collapse
 
brittonwalker profile image
Britton Walker

I don't solely use Tailwind to write py-1 but I think we can all agree py-1 is still faster to write than padding: 1rem Xrem... cOmE oN

 
regislutter profile image
Régis LUTTER

Actually, it's more like
padding-top: 0.25rem;
padding-bottom: 0.25rem;

So I totally agree, I prefer py-1.

 
brittonwalker profile image
Britton Walker

@regislutter Exactly, your example is more accurate. I also want to point out in the newest version you could do this py-[30px] etc. which is very handy.

You can also take what you need and leave what you don't. For example, I probably wouldn't ever write this if the design called for it pt-1 pr-2 pb-3 pl-4 md:pt-2 ... lg:pt-3 ... xl:pt-4 .... just out of preference, especially if you have a lot of other styles going on in it. However, there are a variety different ways to handle you could handle that. You could just write your normal css padding shorthand and write them in respective media queries as necessary.

You could use multiple @apply statements organized by query (or whatever you want, variant, spacing, etc).

.card {
  @apply py-2 px-4;
  @apply lg:py-3 lg:px-5;
  ...
}
Enter fullscreen mode Exit fullscreen mode

Or you could put them in the @screen directive:

.card {
  @screen lg {
    @apply py-3 px-5;
  }
}
Enter fullscreen mode Exit fullscreen mode

A lot of the common css frameworks/tools provide utility classes. I made pretty heavy use of Bootstrap's utility classes way before Tailwind was born. The examples I provided are just one of many things I like and use on a daily basis. It becomes a situation where you or your team would need to agree on the approach based on what works for you and define your house style. At the end of the day all of this could obviously be written by hand without tools and frameworks. These tools are meant to help improve your workflow and should be evaluated for your needs.

Collapse
 
regislutter profile image
Régis LUTTER

I don't see why py-1 is worth than the idea of the post, which is :
--small-padding: 0.25rem;
padding-top: --small-padding;
padding-bottom: --small-padding;

Collapse
 
madeleineostoja profile image
Madi Ostoja Author

The problem with inline CSS is you lose access to every pseudo element, pseudo selector, state, and media queries.

Personally I use CSS-in-JS so the class naming thing isn’t an issue, but even if you were writing regular CSS it seems like a pretty minor problem compared to the sort of things Tailwind introduces

Collapse
 
justindmyers profile image
Justin Myers • Edited on
Collapse
 
seangwright profile image
Sean G. Wright

I'm sad to see a lot of these comments. People seem so angry and offended. 😒

Collapse
 
madeleineostoja profile image
Madi Ostoja Author

Yeah tbh this is gonna be my first and last article on Dev.to

Like I know this is a hot topic, and I mention another library (which I also say you prob don’t need, it’s literally a collection of variables), but damn. They be coming for my throat lol.

Collapse
 
miketalbot profile image
Mike Talbot • Edited on

I too hope you write more articles. Promoting debate is good, the response you've got does contain some comments that show a surprising level of vitriol to something that you've clearly thought about deeply and inspired something you've given to the community for free. We don't have to agree with your conclusions to thank you for your work and your effort in creating this piece.

Collapse
 
juli91 profile image
Juli (she/her)

I'm so sorry for all the hate comments you get. I, for one, enjoyed your article as it was neither one of these "Tailwind is the best damn thing" articles nor a "Tailwind is total crap" article.

And as for what Tailwind can and cannot do: Everyone should just make up their own mind instead of coming for other peoples opinions.

I hope you'll write more articles!

Collapse
 
seangwright profile image
Sean G. Wright

I thought your post was very well written. I hope you continue writing here!

These angry developers feel like they have the one true answer, that their experiences and conclusions must make sense for everyone else. They act like they have ownership over the technology they use because they made the choice to use it, and that these choices represent them as people.

It's immature, disappointing, and in some cases results in cruel and compassionless responses.

You don't deserve this, at all.

These people need to step back and self reflect some.

Collapse
 
helmsb profile image
Blake Helms

There are some valid criticisms on Tailwind but for me at least it misses the true beauty of Tailwind, hyper-productivity.

I have been building web applications using CSS for over 20 years and I have used everything from hand-written bespoke CSS to every framework under the sun but Tailwind was an absolute game-changer for me. I immediatly had a huge gain in my productivity as making the classes utilities allowed me to quickly apply them without leaving the markup. I didn't have to jump from HTML to CSS then back again. Add a class and it just worked.

The classes are also predictable so when I learned the pattern I had an intuitve sense of what was possible. As I found gaps or areas that I wanted to customize I could easily extend them with my own classes.

This hyper-productivity also had the benefit of giving me more "courage" to expirement. I am much more comfortable trying things becuase I can apply a few classes and start getting a feel for how different styles might look.

Tailwind allows me to quickly build great looking applications with a fraction of the effort I've used with other tools and I did not need to learn any technologies that I wasn't already using.

Collapse
 
madeleineostoja profile image
Madi Ostoja Author

Yeah that’s a totally valid use-case for tailwind, and if I was building a quick prototype that didn’t need to scale I’d probably use it myself.

I more wanted to point out some issues that I have come across at scale with it, because it’s often presented as a flawless new way to do things, which isn’t the case

Collapse
 
helmsb profile image
Blake Helms

I guess I disagree with the premise that Tailwind only makes sense for prototypes and can’t scale. I’ve built/maintain a number of projects with some using Tailwind and others using various SASS/CSS frameworks and the Tailwind projects are an order of magnitude easier to maintain.

That is what attracted me to Tailwind. I find it easy to build projects AND easy to maintain.

I’m not saying it’s going to work for everyone but it’s certainly NOT only for PoCs.

Some comments may only be visible to logged-in visitors. Sign in to view all comments.

DEV has this feature:

Settings

Go to your customization settings to nudge your home feed to show content more relevant to your developer experience level. 🛠