Utility-first CSS relies on creating lower-level generic utility classes that can be applied to HTML as needed. There's a lot of overlap here with [[20210927112243-atomic-css]], where classes are created to do a single thing. e.g. m-8
applies a 8px margin, and that's it.
Layout components are similar in this regard too, abstracting utility you constantly rely on. [[20200314214239-layout-components]]
"The more a component does, or the more specific a component is, the harder it is to reuse."
In theory, there's lots of positives here:
However there are some negatives that come up often:
p
tag can give itself a non-standard margin compared to every other p
tag. Although it's also a useful tool in enforcing constraints. e.g. scales for margins, palettes for colours, etc.It often gets compared to inline styles, but that's not really true. Utility-first CSS has better support for wanted constraints (e.g. the systems mentioned earlier), responsive design, component states, tooling, etc.
Keywords: Tailwind, utility CSS, functional CSS