mafinar

mafinar

A little weekend learning: Trying out Tailwind

I (re-)realized I had the book “Modern CSS with Tailwind” bought, never read a page of it until today. With me being a fast reader and this book being 90 page in size, I skimmed through the book fairly quickly.

Tailwind never was convincing to me, from the definition of it, it felt very counter productive. My friends who used it and this book made good enough case for me to actually take it for a spin and see for myself. I actually had a project for this. A Covid19 dashboard I created last year, where I used the CSS framework I love the most- Bulma. Let’s use Tailwind on it to see how it feels like!

Most Liked

mafinar

mafinar

Step 1 - Tabula Rasa

… as far as CSS is concerned! After creating a new branch, I removed all the design and existing CSS framework so that the UI looked from…

to a much more beautifully designed…

^this.

The charts and maps are still the same and will remain so even after the experiment. I do intend to change those too but that is another day’s tale to tell.

Okay, so got my clean slate, now let’s get on with the experimentation!

Note: The system is entirely functional. It just looks a little pale that’s all.

mafinar

mafinar

Step 1.1 Setting up Tailwind

I used this link to setup Tailwind. This commit has this. I also read the book on this chapter but this being a LiveView project I needed a more tailored tutorial. I did use the example given in the book to try out moving and enlarging some titles on the card, they worked (I didn’t commit them because they don’t look good in my particular case).

Interesting things, I went all heroic and modern and what not and decided to NOT use the @4.2 while installing css-loader (The article recommends it, the book doesn’t concern itself with css-loader in its introductory chapter), and was yelled at by the compiler through error messages, using version 4.2 helped. I’m in too much of a hurry to afford not knowing why.

Another thing, VS Code is showing Unknown at rule @tailwindscss(unknownAtRules) on @tailwind directive and while my OCD makes me want to fix it, I can afford not caring for today at least. It’s inconsequential.

So, it works, I brought back my theme.scss and colors.scss and removed Bulma specific variables. Awesome! I can see the font changing and the overall UI changing.

I am not a designer, I am not even design-minded, so it’s more than expected that whatever I do here will suck. Hopefully, it will be better than the first screenshot, since I have matured compared to a year ago (or I’d like to think). But I will not hurt any readers eyes with sharing screenshots at each stage unless there is a noteworthy design change or an aha moment! This time, it just knows Tailwind classes, nothing more, so no screenshots :slight_smile:

mafinar

mafinar

Woke up and took a look into my code. And decided to end this experiment with TailwindCSS and keep this branch as it is, a branch :slight_smile:

There are several things I observed that made me realize TailwindCSS is not for me:

  1. In the wild, when I looked into the examples, very few of them used @apply and most of the examples hurt my eyes plenty. Like the following example:
            <button class="text-base  rounded-l-none border-l-0  hover:scale-110 focus:outline-none flex justify-center px-4 py-2 rounded font-bold cursor-pointer 
        hover:bg-teal-200  
        bg-teal-100 
        text-teal-700 
        border duration-200 ease-in-out 
        border-teal-600 transition">
                <div class="flex leading-5">Next
                </div>
            </button>

I could have done it in CSS too. I already knew about border-radius, and I will need to keep that knowledge in my brain because it’s the framework independent way, however, now I need to keep rounded-*-* in my head. Multiply that by almost all the other properties.

  1. Even if I carefully apply things and get myself free from the overcrowded class situation, I will end up inventing my own way of doing and naming things, which may waste time in cases where I probably would be better off with sensible defaults and override when necessary, or just use CSS classes with CSS properties.

  2. If I am to prototype things where good semantics may not matter, I wouldn’t still use it because I have OCD about code organization and I won’t be able to sleep at night with it, getting back to point 2.

  3. In a team environment, there runs a risk of a case of “escaped applies”, a hard to debug situation where there was a card-image px-4 py-2 rounded left out unintended

  4. It’s slow to compile, probably I am missing some tool or steps but there you go, more tools, more fatigue.

So from my experiment, Tailwind does not teach me anything notable enough to go on with it. Maybe I am old fashioned and maybe I am not a front-end developer which makes me not get a few of its merits, but I will happily go back to the way I did things before :slight_smile:

Please read all of the above with a huge “In my opinion” in mind

Also, I have read this article and I agree with most of what’s mentioned here:

Where Next?

Popular Frontend topics Top

andresriveros
I’m very interested in the Stimulus reflex approach for frontend development: It is a great way to integrate action cable very easily ...
New
AstonJ
Inspired by @dbernheisel’s post here, which CSS framework do you use and why?
New
New
First poster: bot
Why do ARM chips have an instruction with Javascript in the name (FJCVTZS)?. FJCVTZS is “Floating-point Javascript Convert to Signed fix...
New
MikhailPertsev
Finally, I am going to enhance my css skills! I have always somehow ignored this, but now I finally decided to understand animations, tr...
New
New
New
First poster: bot
Type. Type is a directed typing experiment. You choose the direction the letters should flow.
New
riyajohnson
When it comes to selecting a framework for a development project, it’s crucial to make an informed decision. With so many options availab...
New
DevynClark
Front-end Developer Griffin, USA As a student in college looking for a way to break into Front-end Web Development, the rise of things s...
New

Other popular topics Top

ohm
Which, if any, games do you play? On what platform? I just bought (and completed) Minecraft Dungeons for my Nintendo Switch. Other than ...
New
dasdom
No chair. I have a standing desk. This post was split into a dedicated thread from our thread about chairs :slight_smile:
New
New
PragmaticBookshelf
“Finding the Boundaries” Hero’s Journey with Noel Rappin @noelrappin Even when you’re ultimately right about what the future ho...
New
AstonJ
If you are experiencing Rails console using 100% CPU on your dev machine, then updating your development and test gems might fix the issu...
New
AstonJ
Continuing the discussion from Thinking about learning Crystal, let’s discuss - I was wondering which languages don’t GC - maybe we can c...
New
AstonJ
Was just curious to see if any were around, found this one: I got 51/100: Not sure if it was meant to buy I am sure at times the b...
New
PragmaticBookshelf
Author Spotlight: Tammy Coron @Paradox927 Gaming, and writing games in particular, is about passion, vision, experience, and immersio...
New
PragmaticBookshelf
A Ruby-Centric Chat with Noel Rappin @noelrappin Once you start noodling around with Ruby you quickly figure out, as Noel Rappi...
New
AstonJ
If you’re getting errors like this: psql: error: connection to server on socket “/tmp/.s.PGSQL.5432” failed: No such file or directory ...
New