Sitemap

Review: Tailwind CSS

4 min readJan 11, 2018

--

Tailwind CSS has recently earned a lot of attention in the front-end development world. I first heard about it from this tweet and after some investigation and initial hesitancy decided to give it a try. I’m now wrapping up my first deep dive using it in production code and want to share my impressions, most of which are positive.

First, some background: Tailwind CSS is a utility-based CSS library that values speed and practicality over lean, semantic markup. Think guilt-free inline styles. Depending on the scope of your project, you could conceivably develop an entire site without writing a single line of your own CSS. Tailwind is by no means the first or only utility CSS library out there, but there’s definitely been a renewed interest in that philosophy with all of the hype Tailwind is getting.

For the sake of this review, the “traditional” approach I’m comparing Tailwind to consists of writing markup in a templating language like Twig or Blade, then styling it with CSS built with Bootstrap and a preprocessor like SASS. Now let’s get into it.

Installation

Laravel Mix is my build tool of choice. The instructions on Tailwind’s site for integrating it with my existing Mix project via the .postCss method worked as advertised. I generated a tailwind.js with the included CLI tool, copied and pasted the example CSS starter from tailwindcss.com into my build folder, and was up and running. Whether this is faster than installing and configuring whatever frameworks and preprocessors you’re used to will obviously depend on what they are, but as a baseline starting point for new projects, I found this process to be pleasantly quick, especially for a newcomer.

Basic Usage

I highly recommend taking a few minutes to play with Tailwind’s default out-of-the-box styles before you get into configuring tailwind.js or writing your own classes. If you’re coming from a SASS or LESS mindset, your first reaction to Tailwind’s approach will likely be dismay at the sheer number of classes required for even relatively basic elements. Just look at the example on Tailwind’s own site; twelve classes on one button just to give it rounded edges and a purple border! To that I say: You’re right. Your markup will almost certainly be “uglier” than what you’re used to. But you get used to it, and the benefits are worth it — most of the time.

Immediate Benefits

So what are those benefits? The most freeing one, in my opinion, is never having to worry about changes to one element adversely affecting another tangentially-related element. Even with the most diligent front-end developer, large-scale projects using traditional styling approaches are constantly-growing Jenga towers of HTML and CSS in danger of collapsing every time an old class needs updating. Yes, BEM style exists and is a totally reasonable solution to that anxiety. But BEM always felt like more of a workaround than a best practice to me, and with BEM your stylesheet still grows as your number of templates does — a drawback not necessarily true for utility CSS.

Get Politicoder’s stories in your inbox

Join Medium for free to get updates from this writer.

Once you have some familiarity with the syntax and get into a flow writing out styles, you’ll notice a lot of “Wait, that’s it?” moments as you go. No more tabbing back and forth between HTML and stylesheets in your editor or waiting for preprocessors to run between page reloads. No more having to choose between your preprocessor or hot reloading. No more having to go back and check to see what you named that other element that’s kind of like this new one that maybe you can borrow some styles from or extend it or write a mixin or whatever. Just HTML, and occasional referencing of Tailwind’s (very good, for the most part) documentation.

Anecdotally, I’ve also noticed that while the average number of classes per element increases significantly, the amount of nesting necessary to achieve most layouts and functionality actually tends to decrease a bit, as every element can do double duty as a utility wrapper and a semantic tag.

Real-world experience

After about a month of using Tailwind every day in actual public-facing production code and three-ish years of Bootstrap and SASS experience, my conclusion is that where Tailwind really shines is accomodating clients changing their minds about existing elements or making additions after development has started. The larger the project, or the less you know about what it will require down the road, the more benefit you’ll get from Tailwind. It has, for now, usurped Bootstrap in my semi-permanent front-end lineup that I use on almost all of my projects, which tend to be medium-to-large WordPress sites. That said, here are a couple cases where it might not be the best solution:

  • Parallax-y pages with a lot of CSS animations. This style of webpage isn’t as fashionable as it was a few years ago, but still comes up sometimes. Tailwind has minimal absolute positioning utilities and zero utilities for transitions and keyframes. Not to say you couldn’t do the static stuff with Tailwind and add those splashes in with SASS later, but I think to some extent that defeats the point.
  • Multi-developer sites. I will not naively ask you to try to convince your entire dev team at work that they should abandon Bootstrap and switch to this hot new thing. Tailwind is still very young, its future isn’t 100% clear, and for most developers it’s a radical change. Support-wise its documentation is great, but it doesn’t have the long-term backlog of blog posts and Stack Overflow threads that more mature technologies do. For those reasons, I believe it’s still best suited for solo projects.

I’ve put the latest iteration of my build files, which include Tailwind, Mix, and VueJS, on GitHub. Those are my big three for now — I don’t even use SASS much anymore. This could very well be a passing trend that I come home from as soon as I need to absolutely position something or animate an SVG, but for now, I’m enjoying it immensely.

--

--

Politicoder
Politicoder

Written by Politicoder

Web Developer — mostly JavaScript and PHP. Partner at Landslide Digital in DC.