Friday, May 16, 2025
News PouroverAI
Visit PourOver.AI
No Result
View All Result
  • Home
  • AI Tech
  • Business
  • Blockchain
  • Data Science & ML
  • Cloud & Programming
  • Automation
  • Front-Tech
  • Marketing
  • Home
  • AI Tech
  • Business
  • Blockchain
  • Data Science & ML
  • Cloud & Programming
  • Automation
  • Front-Tech
  • Marketing
News PouroverAI
No Result
View All Result

Why Tailwind Doesn’t Work For Me

January 4, 2024
in Front-Tech
Reading Time: 5 mins read
0 0
A A
0
Share on FacebookShare on Twitter



It’s hard to follow a path if you can’t see it. I recommend putting your code guidelines in writing. They should be easy to follow and flexible enough to apply to many situations. Here are some of mine I’ve developed over the past decade:

One project I’ve worked with violates these guidelines I hold dear. You may have heard of it: Tailwind.

Disclaimer
Nobody is perfect. I\’m using Tailwind as an example here, but I want to make it clear that I\’m impressed by and appreciative of the Tailwind team. Tailwind has brought innovative ideas that have improved build speeds and user load times. Some devs love Tailwind and find that they are able to work faster with it. I don\’t. I\’d like to talk about my rules using Tailwind as an example, but I want to make it clear that I\’m not trying to besmirch the creators of Tailwind. They made a very cool thing.

Tailwind is faster to build with a smaller output than some other styling options, like CSS-in-JS. MUI, a popular CSS-in-JS design system, is currently building a new engine inspired by some of the things Tailwind does. By introducing new ideas, Tailwind is pushing web dev forward. However, I do not agree with some of their syntax choices nor how debugging works with their system. They probably discussed these points and decided the trade-offs were worth it. Engineering is researching, planning, and then choosing the path with the best balance of pros & cons. I don’t like where they ended up, but I respect how they got there.

Convention Over Cleverness
Write your code with other people in mind. That other person might even be future-you. I’ve seen people argue that Tailwind is just like CSS and that the knowledge transfers between them. I very much disagree. Tailwind gets clever with names instead of sticking with well-established CSS conventions. For example, what do you think this Tailwind class does?
<code><flex></code>

As a CSS veteran, I had to look it up.
<code>display: flex; flex: 1;</code>

Those both seem like possibilities. I figured it would be the second one, but turns out it’s display: flex. Why generate confusion by introducing a shorthand when you could stick with the well-established CSS name? Predictable code means sticking to conventions and naming patterns. Want to guess what the classes hidden and invisible do?
<code>hidden >> display: none; invisible >> visibility: hidden;</code>

Maybe the W3C got it wrong in naming these properties, but it did so a long time ago, and there\’s no changing it now. Wouldn\’t display-none have been far clearer? Plus, it\’s easier to find in the editor’s autocomplete. That was a particularly heinous example, but there are others that made me question my sanity. Can you guess which one of the following Tailwind classes doesn’t exist?
<code>border-0 border-1 border-2 border-4 border-8</code>

It\’s border-1. Instead, use just border to apply a 1px border. What? You could maybe argue that the actual classes are all multiples of 2, so that makes sense somehow, but it\’s inconsistent, unpredictable, and frustrating. How many times have you needed an 8px border? Most of the time, its going to be 1 or 2 pixels. I had to go verify that border-8 = 8px because my experience with Tailwind was mostly on spacing and margins are measured in units of 1/4rem (so mb-8 = 2rem bottom margin) which is its own maddening inconsistency. – Bradley Momberger, reviewer

Tailwind advocates might be saying, \”Ok, but border gives you a simple shorthand for the most common border width.\” Ugh, kinda? This is only true for someone who regularly works with Tailwind. By having border, Tailwind has established the higher importance of a 1px border but ignored the developer experience. I just had to go to the Tailwind docs to reduce the size of a border-2 because changing to border-1 didn\’t work. That is a massive waste of developer energy. This simple violation of Tailwind’s own naming convention broke my train of thought and forced me to research something that should have been mindlessly simple for someone who has been writing CSS since <marquee /> was a thing.

Verbosity Over Brevity
In the previous example of border, Tailwind broke it’s own convention and it did it just to save 2 keystrokes. Whether we are talking about JS variable names, CSS class names, or just code comments, character length does not matter to the final product. Your build system should be stripping out comments and minifying the rest. There is no good reason to hurt readability to save characters. For classes that are a 1:1 with real CSS, which is most of Tailwind, I would have replaced the colon with a dash OR kept the dash and removed the spaces. Tailwind uses the dash for media queries, but there are some other possibilities.
<code>/* Assume sm is a breakpoint size */
sm_display-flex
sm_display:flex
[sm]display:flex</code>

Using a naming convention like this would be far more straightforward for people who are familiar with CSS, reducing the learning curve. The advantage of Tailwind is in build size, not naming. This \”cleverness\” of Tailwind hits me over and over again, sending me back to the docs for CSS styles I already know. This naming convention would add maybe 25% to 50% to the space a list of Tailwind classes takes up. I don\’t think that matters much at all. Tailwind is already naturally verbose (as is CSS). Many style definitions already wrap to another line. Adding 50% wouldn\’t matter much. The build system is going to strip all these classes down to a few characters and the final build will be unaffected.

Ease of Debugging
HTML, JavaScript, or CSS, at some point, you\’ll run into unwanted behavior that you need to debug. Having tools to enable the debugging process is critical. I should mention that Tailwind does have excellent editor plugins. The autocomplete works well. Not well enough to solve all the problems I mentioned earlier, though. \”Okay, then what\’s the debugging issue?\” When refining a layout, I open the site in the browser and make adjustments in the dev tools. This lets me see immediately what each CSS change does.

With traditional CSS, you might have a singlelist-item class that sets font size, padding, border, and color values.
<style>
.list-item {
font-size: 0.875rem;
line-height: 1.25;
padding: 0.5rem 0.75rem;
background-color: var(–background-light);
border: 1px solid var(–border-color);
border-radius: var(–border-radius-md)
}
</style>
<li class=\”list-item\”>First thing</li>

With Tailwind, there are no unique classes. Instead, an element gets assigned multiple classes that each do a small thing, usually setting a single CSS property.
<li class=\”text-sm py-2 px-3 bg-background border-input border rounded-md\”>
First thing
</li>

By avoiding unique, component-specific classes, Tailwind can create a smaller stylesheet and therefore a slightly faster page load. However, this is a problem when debugging, as there is no simple way to adjust component styling using browser dev-tools. I can\’t simply bump up the padding on one group of elements using the browser tools because that same py-2 class can be used by several other elements on the page. Trying to adjust styling for one component type will also affect others. Adjusting styling in dev tools can be unpredictable with Tailwind.

One solution to the dev tools issue is to set the styling on that specific element as shown below, and that works for individual elements, but when you want to change a set of like components all at once, I’m not sure what to do. Tailwind is very fast, so I suppose I could make changes in the editor instead, but that’s still slower than doing it in the browser tools .

There was a time in the React world when Redux was extremely popular because the Redux dev tools were far superior to any other state management option. Redux is verbose with a steep learning curve and scales poorly, but the ability to debug effectively and efficiently was often worth it. When you write code, do it in such a way that it\’s easy to debug and maintain. Some examples include:

Avoid choices that are not easily worked with in established debugging tools
Break code across multiple lines instead of fancy one-liners
Use descriptive naming to ease keeping track of what each variable holds

Stop picking on Tailwind! Tailwind does get a lot of things right under the hood. Tailwind solves a lot of performance issues…



Source link

Tags: doesntTailwindwork
Previous Post

8 Best Practices for Writing Clean and Maintainable Code

Next Post

Intel launches Articul8 AI with DigitalBridge

Related Posts

The essential principles of a good homepage
Front-Tech

The essential principles of a good homepage

June 7, 2024
How to measure and improve user retention
Front-Tech

How to measure and improve user retention

June 6, 2024
Push Animation on Grid Items
Front-Tech

Push Animation on Grid Items

June 5, 2024
How to build a Rails API with rate limiting
Front-Tech

How to build a Rails API with rate limiting

June 4, 2024
Introduction to the B.I.A.S. framework
Front-Tech

Introduction to the B.I.A.S. framework

June 3, 2024
Blue Ridge Ruby is exactly what we need
Front-Tech

Blue Ridge Ruby is exactly what we need

June 3, 2024
Next Post
Intel launches Articul8 AI with DigitalBridge

Intel launches Articul8 AI with DigitalBridge

Every common UI menu icon and its use case

Every common UI menu icon and its use case

Google and MIT Researchers Introduce Synclr: A Novel AI Approach for Learning Visual Representations Exclusively from Synthetic Images and Synthetic Captions without any Real Data

Google and MIT Researchers Introduce Synclr: A Novel AI Approach for Learning Visual Representations Exclusively from Synthetic Images and Synthetic Captions without any Real Data

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Trending
  • Comments
  • Latest
Is C.AI Down? Here Is What To Do Now

Is C.AI Down? Here Is What To Do Now

January 10, 2024
Porfo: Revolutionizing the Crypto Wallet Landscape

Porfo: Revolutionizing the Crypto Wallet Landscape

October 9, 2023
23 Plagiarism Facts and Statistics to Analyze Latest Trends

23 Plagiarism Facts and Statistics to Analyze Latest Trends

June 4, 2024
A Complete Guide to BERT with Code | by Bradney Smith | May, 2024

A Complete Guide to BERT with Code | by Bradney Smith | May, 2024

May 19, 2024
How To Build A Quiz App With JavaScript for Beginners

How To Build A Quiz App With JavaScript for Beginners

February 22, 2024
Saginaw HMI Enclosures and Suspension Arm Systems from AutomationDirect – Library.Automationdirect.com

Saginaw HMI Enclosures and Suspension Arm Systems from AutomationDirect – Library.Automationdirect.com

December 6, 2023
Can You Guess What Percentage Of Their Wealth The Rich Keep In Cash?

Can You Guess What Percentage Of Their Wealth The Rich Keep In Cash?

June 10, 2024
AI Compared: Which Assistant Is the Best?

AI Compared: Which Assistant Is the Best?

June 10, 2024
How insurance companies can use synthetic data to fight bias

How insurance companies can use synthetic data to fight bias

June 10, 2024
5 SLA metrics you should be monitoring

5 SLA metrics you should be monitoring

June 10, 2024
From Low-Level to High-Level Tasks: Scaling Fine-Tuning with the ANDROIDCONTROL Dataset

From Low-Level to High-Level Tasks: Scaling Fine-Tuning with the ANDROIDCONTROL Dataset

June 10, 2024
UGRO Capital: Targeting to hit milestone of Rs 20,000 cr loan book in 8-10 quarters: Shachindra Nath

UGRO Capital: Targeting to hit milestone of Rs 20,000 cr loan book in 8-10 quarters: Shachindra Nath

June 10, 2024
Facebook Twitter LinkedIn Pinterest RSS
News PouroverAI

The latest news and updates about the AI Technology and Latest Tech Updates around the world... PouroverAI keeps you in the loop.

CATEGORIES

  • AI Technology
  • Automation
  • Blockchain
  • Business
  • Cloud & Programming
  • Data Science & ML
  • Digital Marketing
  • Front-Tech
  • Uncategorized

SITEMAP

  • Disclaimer
  • Privacy Policy
  • DMCA
  • Cookie Privacy Policy
  • Terms and Conditions
  • Contact us

Copyright © 2023 PouroverAI News.
PouroverAI News

No Result
View All Result
  • Home
  • AI Tech
  • Business
  • Blockchain
  • Data Science & ML
  • Cloud & Programming
  • Automation
  • Front-Tech
  • Marketing

Copyright © 2023 PouroverAI News.
PouroverAI News

Welcome Back!

Login to your account below

Forgotten Password? Sign Up

Create New Account!

Fill the forms bellow to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In