Hacker News new | ask | show | jobs
by ajanuary 1043 days ago
One of the selling points that Tailwind pushes that I haven't seen other people mention here is that inline styles are _too_ flexible. You can do `style="color: red"`, but you can also do `style="color: #FE0005"` or `style="color: #FE1111"`.

While tailwind lets you write your styles in the same _location_ as the style attribute, it allows you to restrict what _values_ you can use. You can set up a colour palette so that when you say `class="red"`, it's the shade of red that you (or your designer) picked, and your colleague can't decide to pick a slightly different shade for their component.

1 comments

Can't this be solved by creating small css classes for your colour palette like font-color-primary, background-color-warn, etc? The benefit being that anyone who needs to include these only needs to think about the context and have consistency everywhere.
Yup. This isn’t the killer feature of tailwind that’s impossible to get any other way. It’s one component of a bigger solution. But why it’s relevant here is it’s an example of how that bigger solution is different to just using style attributes.