I've been playing around with Tailwind CSS a lot since it's release, and so far it's been really impressive to see its growth over the last few yea...
For further actions, you may consider blocking this person and/or reporting abuse
This is absolutely the most jarring part of Tailwind, and unfortunate that it's inherently the first thing you experience when starting with Tailwind.
I'm honestly surprised that there isn't a collection of standard styles (at least I haven't heard of any yet) that has a few baseline starters to "fix" preflight and offer a quick starting point to get some standard styling back.
So much yes @terabytetiger !
When I first installed Bootstrap the first experience was "Everything looks pretty decent", but Tailwind often feels like a I'm starting from a blank slate. I think I'm in the same boat as you where I kind of expect semantic HTML to render nicely.
Tailwind isn't designed to give you a "generic" base style - it wants you to create your own visuals exactly as you need them - For us this is perfect because every design we produce is unique, if we had to remove all this extra fluff added for us it would be even more of a pain.
If you need a base style - then you create your own that you can pull into future projects, or find a UI Library that does it - there's plenty that people have already created :)
In researching something else, I have now stumbled upon tailwindcss-typography.netlify.app/ which (kind of) resolves most of my complaints here.
I wish the
.prose
didn't have to be added everywhere to apply it, but I guess it's better than nothing 🤷♂️I agree. Utilities are great, and Tailwind took it to the next level. However, something doesn't let me go all in for that. I still prefer Bootstrap. They have introduced utility classes way back, but maybe because of a lack of proper documentation and example, people didn't know exactly what to do with them.
Because of this, I've created a project in which I included a bunch of utilities using the Bootstrap 5 API. Now you have the best from the two worlds: basic components and utility classes for faster customization. Here's a link to the docs: webpixels.io/docs/css/1.0/installa...
Tailwind, like Bootstrap and all the rest, is for developers who can't be arsed to learn proper CSS. It's a crutch. And when you can't walk, a crutch is great. But eventually you begin to see the downsides of walking with a crutch. You want more.
In a long career as a developer, I have used all kinds of frameworks and libraries. I've mostly given up on frameworks. They make it easy to get started, but eventually they get in your way and make things much harder.
Libraries are a bit better, but depending on other devs to maintain their code, keep it secure and tested, keep it up to date, etc. is a fool's errand. So I have concluded that the fewer dependencies, the better. Add one only when you need most or all of its functionality and writing it from scratch would be onerous.
There is nothing that any of these UI libraries gives me that I can't add myself quickly and easily -- and I've used them all going back to the first versions of scriptaculous. With CSS variables and CSS modules, there's really no reason to use anything else -- unless you simply can't be bothered to learn CSS.
As for the cognitive load of context switching between JS/TS, HTML, and CSS... please. Writing HTML as JSX or CSS as CSS-in-JS is the same cognitive load as putting it in a separate file. Using separate files keeps each clean and focused. It's not about separation of concerns but about separation of duties.
Svelte does a nice job of separating the duties, but then forces them into a single file. That's too bad.
When I code, I keep my component in one pane and my CSS (module) in the pane next to it. If I've drawn my boundaries correctly, all the code in each pane fits on one screen (admittedly, I have big screens). It's all right in front of me. And if I keep to the single responsibility principle, those screens stay short and focused.
That is how you reduce cognitive load -- not by memorizing yet another DSL so you can add ten classes to a component. And Tailwind promotes breakpoints (sm, lg, etc.), which is clearly not the right way to do things. Interfaces should adapt smoothly to changes in the size and aspect ratio of the portal and the zoom.
I know Tailwind is the new hotness right now. I've been forced to use it more than once already. But in a couple of years it will seem obsolete and foolish. Why wait?
Bookmarking this for viewing later. If I ever get this advanced at writing css this seems like a great guide. Excellent post!
Thank you @kirkcodes !
It looks like we have a shift towards using more "vanilla" code. Both in CSS, JS and HTML in general. I really like that trend. Vanilla is a loaded word though. I think it has become a hallmark of something "not great". But I think many of us has experienced the actual "not great" feeling of going in to maintain a webapp written perhaps 2 years ago by using all the libraries&frameworks that were cool back then: If you chose to upgrade the libbraries&frameworks, you are in for one helluva ride. On the other hand, if those webapps were written using mostly vanilla tech, you may end up not having to do a single upgrade. Go Vanilla!
I seriously hope we are on a trend towards more "vanilla" code with CSS, JS, and HTML. I'm appalled at the current state of front end over-engineering.
Every few month I look into Tailwind but after reading and trying to style my first components, I always cannot believe how long and ugly this classes look and feel. Utilities are okay for some things. I have my own grid system so I can already put anything into the right columns as I wrote HTML but after that I switch to CSS and write the styles of the component - without almost ever having to change the HTML again, with auto reloading. This is no way worse than Tailwind. I just don't get the advantage. But of course I know - it is not your fault TW, It is mine 🙃
Do you think you'd be up for revising the "Preflight" and "Javascript Dependencies" points to something potentially more (excuse the term) "accurate" ?
Preflight - this is completely optional, just don't include the directive for it - in fact you can add normalize if you like? Maybe just a revision to say you can disable or replace it if you want.
Javascript dependencies - If you want to avoid adding TW to your build chain, simply use the official CLI tool which lets you build on the fly without touching the rest of your code base. From memory it's a simple as "npx @tailwindcss/cli build" (plus some extra args)
I appreciate these are things that have caught you out, but they're not faults of Tailwind, they're caused by how it's been used. If you drive a car into a river and complain it sank - it's not the cars fault :P
While this is true, I don't think it's particularly relevant to the author's point - which is that when you follow the Installation page's instructions, you end up with fully reset styles and it can be jarring to new users.
The first line of the installation page which discusses this option is:
and under the "Using Tailwind via CDN" section there's this statement:
Everything the author has run into that you're calling out is from following the recommended installation guide in the Tailwind docs and will align with the experience of many new users.
Not really interested in any excuses tbf - The fact of the matter is sharing false information.
If people with less experience read that - they will repeat and take it for truth.
If a balanced argument is provided, they will be educated with both sides.
The only thing I like about Tailwind is that you don’t have to switch between files while building a component for instance...
This is what I love in Marko, but also Svelte or Vue.
Svelte is awesome
@zzoukk That is a really nice feature (React has the same appeal to me)! I have tried using a split tab in my code editor, but it never quite feels the same :/
Great article @mikerogers0 !!
This was a game changer for me honestly. Not writing a wall of messy CSS it does bring me so much pleasure and makes writing CSS so much cooler.
Thank you @bogdaaamn !
I can't live without glob import now, it makes everything better!
great article, Mike. I've learned a lot!
Thank you @clandau 🎉🙏
I made the following library just before someone referred me to this helpful post :)
github.com/zvizvi/freewindcss