I’m working on a few new project ideas for the first time in a few years. When you work on the same thing for a long time you can become comfortable with just what you have. Well, I do at least. Comfort is good and it allows me to move fast. But every time I start a new project I try and play with something a bit new to get outside my comfort zone.
One of the tools I’ve been playing with has lately been Tailwind CSS. This one is quite a bit different than anything I’ve used for CSS before.
Traditionally, I don’t like CSS frameworks. I find them overbearing, overly-opinionated, and bloated with tons of components and utilities that I never end up using. I’ve worked on countless projects with Bootstrap, Foundation and the like. They are great frameworks and they certainly have their benefits. But it’s just too much for me.
A few years ago, when I started working on Air Mail, I just started from a basic CSS reset and added my own components as I went along. The front-end of the public site is very simple but the back-end content manager is much more complicated. There’s a ton of CSS. All of it is custom, and all of it was tailor-made for the specific use cases I had. It works great, but it all seems a bit heavy. I’ve been trying to figure out a better way forward.
Tailwind takes a completely different approach. I’ve heard it described as an “API for your design system.” That’s clever. Instead of building custom CSS (or using a normal framework) Tailwind allows you to use utility classes to change the look of the markup. It’s almost like old-school inline stylesbut with more more power and control. Controlling variants and breakpoints from just class names is pretty handy.
The Tailwind docs give a nice example of why the utility-first approach can be productive.
I like that it provides a basic design system in a box. There are sensible defaults, all that can be customized, but then the framework just provides a ton of utilities to get you what you need. It’s refreshingly simple.
Last but not least: to fix the bloating problem Tailwind is designed to be used with PurgeCSS to remove any code on build that your site doesn’t need. This is really nice.
It’s not all roses, there are going to be some hiccups. That’s a heck of a lot of classes floating around in my markup and it’s going to take me some time to get used to that. This approach is new to me, but I’m excited to give it a spin.