Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I notice in the config you specify "colors" and "fonts" but also "fontFamily", not plural. Ugh. I hate inconsitancies like this. They make it a lot harder to predict how to specify what you want, and it's likely that someone in the future will "fix" it and you'll end up with deprecation warnings all over the place.

No thanks.



Creator of Tailwind here — what you're seeing here actually is a best effort attempt to be consistent and predictable.

Keys in the config file generally correspond with the CSS property they refer to, and we use the singular form to make it match the CSS property.

There are 3 exceptions, which are "colors", "spacing", and "screens", and these are sort of special keys that don't map to anything in CSS. The "colors" and "spacing" keys are more like reusable variables that are consumed by the property-specific keys like "backgroundColor", "fill", and "borderColor" in the case of "colors", and "width", "height", "gap", and others in the case of "spacing".

The "screens" key is a list of breakpoints for your project, which also doesn't map to an underlying CSS property.

Originally we tried to keep things really abstract and group things together under concepts like "spacing", "typography", whatever, but ultimately found it was more flexible and predictable to make it possible to customize every CSS property using the exact property name, while only providing a couple high-level things like "spacing" and "colors" that you can use to update other dependent keys at once.

Getting complex config files right is unfortunately hard and it's not perfect for sure. At this stage in the project it's a delicate balance between improving things and maintaining backwards compatibility. Totally appreciate what you're saying, just wanted to do my best to clarify though as I'm equally picky about this sort of consistency.


I can understand non-CSS things being different, though it still feels wrong to have them plural when nothing else is, but then... "spacing"? Why isn't that plural, when the other 2 are?

I appreciate all the work that goes into something this large, but that just makes me more sad that this jumps out at me so quickly when I look at the examples. This kind of thing made PHP a laughing stock for many, many years before they finally bit the bullet and standardized their function parameter order, etc. And I say that as someone who does PHP for their day job by choice. (Among other languages.)


Tailwind is mostly consistent, but I do sort of wish it were color-gray-500 instead of text-gray-500, and I think some of the sizes are a bit confusing in terms of when you can use what.

What would you do if backwards compatibility were out the window?


Author here, I will add my kudos for the Tailwind API. The more I've used it and internalized its structure, the more I appreciate the care and effort of its API.


That's because fonts is a collection of the singular font. Colors, the same for color. fontFamily is precisely what is says; a font family. It's a singular unit. There is no inconsistency here.


When configuring the settings, it uses `fontFamily`, singular, to set up multiple font family options (eg. options for "heading" and "body" in their example). `colors`, however, is plural here.

When applying them later in the code, they're both singular since they're specifying a specific family/color.

I agree with GP that this inconsistency shakes my confidence in the package.


Tailwind is free and open source. If it really shakes your confidence with the entire system, you could certainly consider opening a discussion or PR. I've been using Tailwind in production and I never even really thought about it. It just seems out of place that of all the incredible work Tailwind is doing, this potentially minor issue is enough to say "well then nevermind".




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: