TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Tailwind: A Utility-First CSS Framework

327 pointsby Ethan_Mickover 6 years ago

29 comments

adamwathanover 6 years ago
Author of Tailwind here! If you haven&#x27;t worked with a library like this before, I promise your gut reaction will be &quot;holy hell this is the worst thing I&#x27;ve ever seen&quot; (it was my reaction too!)<p>You really do have to try it to shake that impression.<p>If you need a bit more convincing before you&#x27;re willing to try it, I wrote an in-depth article a while ago that documents my journey from a &quot;semantic classes&quot;-loving HTML&#x2F;CSS purist to a utility-loving heathen:<p><a href="https:&#x2F;&#x2F;adamwathan.me&#x2F;css-utility-classes-and-separation-of-concerns&#x2F;" rel="nofollow">https:&#x2F;&#x2F;adamwathan.me&#x2F;css-utility-classes-and-separation-of-...</a><p>If you want to watch it in action, here&#x27;s a screencast where I rebuild the Netlify UI in an hour and a half without writing any custom CSS:<p><a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=_JhTaENzfZQ" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=_JhTaENzfZQ</a><p>...and if you want &quot;social proof&quot;, here&#x27;s an interview I did with Diana Mounter who leads the design systems team at GitHub about how moving to a utility-based approach has made things infinitely more maintainable for them, and given their developers a lot more confidence:<p><a href="http:&#x2F;&#x2F;www.fullstackradio.com&#x2F;75" rel="nofollow">http:&#x2F;&#x2F;www.fullstackradio.com&#x2F;75</a><p>If you have any questions I&#x27;ll be checking the comments, thanks!
评论 #18085409 未加载
评论 #18085917 未加载
评论 #18086836 未加载
评论 #18089946 未加载
评论 #18090785 未加载
评论 #18091882 未加载
评论 #18086288 未加载
评论 #18085697 未加载
评论 #18090025 未加载
评论 #18087740 未加载
评论 #18085768 未加载
评论 #18086397 未加载
jasimover 6 years ago
Tailwind is the best thing that has happened to CSS Frameworks in the last 10 years.<p>* Define the essence of your design in a JSON - typography, colors, spacings, shadows, borders et al.<p>* Anyone in the team including backend developers can create new interface components without waiting on a designer, thanks to well-defined scales that compose well.<p>* The component (HTML+CSS) is the unit of abstraction. eg: &quot;ProfileCard&quot;. Inside ProfileCard you&#x27;ll use Tailwind&#x27;s utility classes to build your component. You reuse this component everywhere, and if you have to &quot;change a button&#x27;s padding across the product&quot; (which to me is far too rare) you open your component files and change them there.<p>* It is so easy to build UIs - you don&#x27;t have to name every single element in the DOM - these names are _only_ to act as &quot;hooks&quot; into the CSS, and serve no abstraction. With Utility classes you can just assemble them in the HTML without touching the CSS<p>* Tailwind has excellent documentation and great conventions - this means between projects all you need to know is their particular scale. Don&#x27;t have to learn a new UI framework everytime.<p>* Consistency, consistency! Thanks to design scales.<p>* Works so well for custom UIs. Have your designer do absolutely original designs in Sketch, and first transcribe their scales into tailwind.config.js, and voila! start pushing out its HTML at breakneck speed.
评论 #18086262 未加载
edhelasover 6 years ago
I personally have an issue with this &quot;Utility&#x2F;Functional&quot; CSS pattern.<p>To me I still think that the good old &quot;HTML describe how the content is organized, CSS describe how this content looks like&quot; is the way to go. In the end it&#x27;s how CSS and HTML were designed at first.<p>But when I see that<p><pre><code> &lt;div class=&quot;bg-white mx-auto max-w-sm shadow-lg rounded-lg overflow-hidden&quot;&gt;&lt;&#x2F;div&gt; </code></pre> I&#x27;m sorry but it just doesn&#x27;t feels right to me.
评论 #18084805 未加载
评论 #18084983 未加载
评论 #18084766 未加载
mcgwizover 6 years ago
All CSS &quot;frameworks&quot; should be thought of as utility libraries, including Bootstrap. If you apply the framework classes directly to your HTML, you&#x27;ve tightly-coupled your HTML (which is already tightly-coupled to your information architecture) to an implementation detail of your presentation code.<p>Most frameworks support some kind of re-use of CSS declaration blocks - use that feature to build your components from the primitives they provide, but also add a layer of indirection by putting those components behind a semantic class name. Voila, loose-coupling with all the productivity benefits of the frameworks.<p><pre><code> &lt;button class=&quot;login-button&quot;&gt;Login&lt;&#x2F;button&gt; .login-button { @apply .btn-primary; } .btn-primary { @apply .font-bold .py-2 .px-4 .rounded; }</code></pre>
评论 #18090230 未加载
fideloperover 6 years ago
I DEFINITELY recommend trying this out before you decide utility CSS isn&#x27;t for you.<p>The practical dev workflow of using tailwind is a breath of fresh air.<p>Coming back to old projects with bespoke CSS is SO PAINFUL to edit&#x2F;change compared to something built in Tailwind.<p>You absolutely also have the power to make css components&#x2F;abstractions as well.
mstgover 6 years ago
People please don&#x27;t judge without giving it a try. Just signed up to write that Tailwind truly changed the way I work. Centralized configuration for styles, colors etc.<p>Tailwind is the only CSS framework I use since I discovered it and I&#x27;m gradually converting my&#x2F;company projects to use it.
benfrainover 6 years ago
I tried the utility approach many years ago and while I can see the appeal in some situations I think it’s far from a panacea. My journey led to me writing <a href="http:&#x2F;&#x2F;ECSS.io" rel="nofollow">http:&#x2F;&#x2F;ECSS.io</a> The opposite way of tackling CSS at scale. Instead of abstraction I opted for isolation.
maouidaover 6 years ago
Recently I had to do some updates on a UI that used tailwind framework. It was the most unpleasant experience I have ever had. I quickly got eye strain looking at all those attributes.<p>Keep HTML for HTML and CSS for CSS.
blairandersonover 6 years ago
Hi There, have you tried Tachyons?<p><a href="https:&#x2F;&#x2F;github.com&#x2F;tachyons-css&#x2F;tachyons" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;tachyons-css&#x2F;tachyons</a><p>Its similar, but has been around since 2015.
评论 #18086344 未加载
sanborover 6 years ago
It is convenient but you are not separating markup and presentation. I think the whole point of css is to swap stylesheets and get a different presentation, like demostrated by <a href="http:&#x2F;&#x2F;www.csszengarden.com&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.csszengarden.com&#x2F;</a> BEM&#x2F;OOCSS lets you do this.
评论 #18085225 未加载
评论 #18085323 未加载
评论 #18085247 未加载
petemillover 6 years ago
I do see the &#x27;utility&#x27;(!) of this kind of approach to css, but have a main issue on responsiveness. Yes, the solution commonly touted is to define global breakpoints: &#x27;small&#x27; &#x27;large&#x27;, etc. But for me defining those globally is too narrow. Sometimes different groups of components need to respond differently, with context. More worryingly, soon we&#x27;ll move to &#x27;element&#x27; queries, which should suit better than screen-based media queries. We&#x27;ll be able to say &#x27;when this component is squeezed down to &lt; 500px wide, then wrap the second element underneath the first. That approach is more compatible with modern component architecture. But I don&#x27;t see a context-specific or even component-specific solution immediately with this framework.
thinkxlover 6 years ago
I like Tailwind. I think the appeal here is to write less CSS, get things done faster, have a consistent design and the maintainability. All good so far.<p>But let&#x27;s remind everybody that this is only one approach of many you can use.<p>One approach that can solve problems Tailwind tries to is proper planning. An initial style guide can show you that the `author-bio` component looks similar to `article-preview` (taken from the author&#x27;s blog post[1]), so you beforehand plan for that HTML and CSS and create a component you can reuse.<p>Of course, you could have decisions made after the fact and go back and change stuff; nothing is bulletproof.<p>- [1] <a href="https:&#x2F;&#x2F;adamwathan.me&#x2F;css-utility-classes-and-separation-of-concerns&#x2F;" rel="nofollow">https:&#x2F;&#x2F;adamwathan.me&#x2F;css-utility-classes-and-separation-of-...</a>
bennofsover 6 years ago
An important difference in my mind is between designing a web application vs designing a web document.<p>In the document case, it is possible to mostly keep the document semantic and apply styling via CSS. It matches the content&#x2F;style separation well.<p>For web applications, I really like tailwind-like approaches, for multiple reasons:<p>* changing the style globally is probably hard anyway without adapting the HTML as well (as in the app case, often lots of other things depend on margins etc for example and you have a lot less uniformity&#x2F;more special cases than in the document case)<p>* because there is less uniformity, the reuse aspect of the traditional content&#x2F;presentation split is greatly reduced anyway<p>* web apps often use component based frameworks already, so you still get reusable components
albedoaover 6 years ago
The big thing that Tailwind brings to functional CSS is the emphasis on and mechanisms for composing from utility classes.<p>This is something that went understated in other functional libraries, even though composition has been possible for years using preprocessors. So when people saw Tachyons, for instance, they would recoil at what they saw as an unmaintainable mess even though the underlying theory is sound.<p>I really like the work Adam is doing and where he is leading the conversation. I will read anything he writes, too. He&#x27;s great at expressing his ideas and rallying you around things you didn&#x27;t know you care about.
redonkulusover 6 years ago
How is tailwind different than Atomic CSS? <a href="https:&#x2F;&#x2F;acss.io" rel="nofollow">https:&#x2F;&#x2F;acss.io</a><p>Small utility classes without writing CSS, seems like the same thing.<p>Disclaimer: I worked with the devs that created it.
评论 #18088141 未加载
pssflopsover 6 years ago
Wow, the letter spacing and intuitive responsive design is very impressive. While I can&#x27;t quite yet abandon bootstrap, this looks like a great alternative.
flatsover 6 years ago
We switched over from a Bourbon-based SASS framework at my work to Tailwind several months ago &amp; it has been fantastic. I was very negative about it at first - “isn’t this just a crappier version of inline styles?” - but I’m a convert. It’s customizable, it enforces consistency, and it dramatically reduces the amount of CSS you have to write, which is a good thing on several levels. Give it a try.
k__over 6 years ago
<i>&quot;Separation of concerns&quot; is a straw man</i><p>So true.<p>That&#x27;s why CSS-in-JS is awesome.<p>Everything is in one component, nobody cares anymore if you need to edit markup AND styles.
评论 #18091810 未加载
aarondfover 6 years ago
I&#x27;ve been using Tailwind for about a year, and it has really put the joy back into using CSS for me. I know that&#x27;s crazy to say, but I used to always have <i>so</i> much trouble figuring out what to name things and popping back and forth between HTML and CSS. It was super frustrating, and now I can just flyyyy while building out frontend.
robmerkiover 6 years ago
Please give Tailwind a try before knocking it. The syntax seems strange, but after 15 minutes you&#x27;ll be in love. It doesn&#x27;t work for every project, but it&#x27;s a great tool to have in your arsenal. I&#x27;ve been following Adam and Steve on Twitter for quite some time, and these guys are total pros.
_fbptover 6 years ago
I can only imagine the lack of semantic classes makes it almost impossible for end-users to reliably restyle the page using Stylus userstyles. I&#x27;d say this type of CSS is hurting power users.
ssijakover 6 years ago
Btw, nothing is preventing you from combining Tailwind with your other methods of writing CSS. For example you could write CSS Grids for general layout and use Tailwind for styling components.
platzover 6 years ago
I started a side project with tachyons.io, but it seems i probably should&#x27;ve gone with tailwind.<p>Really i don&#x27;t need the compile-step, just really wanted to get out of the bootstrap canton
giancarlostoroover 6 years ago
Would be nice to see sample templates of what it all looks like in practice.
评论 #18084716 未加载
评论 #18109470 未加载
uhoh-itsmaciekover 6 years ago
What&#x27;s the difference between tailwind and tachyons?
评论 #18087065 未加载
interfixusover 6 years ago
&gt; <i>&lt;div class=&quot;bg-white ...&quot;&gt;</i><p>Are we missing a [1996] in the title?
andrewmcwattersover 6 years ago
One of the biggest strengths of Bootstrap is that everyone uses Bootstrap. I can come to a company, use Bootstrap, and expect that new employees will also use Bootstrap or that it&#x27;s already been used there! It&#x27;s so common in the industry.<p>It also means, for front-end developers like me, that I can create a company theme on Bootstrap, and get junior developers to use it can feel comfortable with being able to implement the brand design language and not have to pixel-fiddle. Not only does this strengthen the technical skillset of my team, but it also helps keep standards high when dealing with offshore resources.<p>We can get them to build UI for entirely separate projects, slap our branding on it, and dramatically cut down on resource allocation, time, and effort.<p>So, here&#x27;s the thing: this is great, but Bootstrap also has utility classes these days. If I use Tailwind, or Foundation, or Bulma, I immediate lose out on developer leverage. This is so much more powerful than moving some classes around.<p>Approaching all of these design concerns in a slightly different way just isn&#x27;t powerful enough to outweigh the leverage Bootstrap has over everything else out there.<p>It&#x27;s just not significantly different enough. It doesn&#x27;t standout to me. In fact, how it differentiates in its introduction is a _con_ to me. No, the industry doesn&#x27;t need complete UI kits, design languages vary enough that this could provide additional undesired weight, however people use buttons, drop-downs, and many other common components _all the time_.<p>A major competitor to Bootstrap in the arena would need to do something revolutionary.
评论 #18086277 未加载
评论 #18087828 未加载
gcb0over 6 years ago
&quot;it doesn&#x27;t have a default theme&quot; ...One paragraph later &quot;here&#x27;s a business card in the default theme&quot;<p>technically, it have all the themes to the point that picking up individual color for everything make it as unmaintanable.
JohnH42over 6 years ago
&quot;bg-white mx-auto max-w-sm shadow-lg rounded-lg overflow-hidden&quot;<p>5 years ago, it should had help some dudes but right now ... choose foundation&#x2F;bootstrap&#x2F;materialcss ... or build your own BEMized css ...