1.1 KiB
title | pubDate | permalink | tags | ||
---|---|---|---|---|---|
With utility styles, your CSS stops growing | 2023-03-22 | daily/2023/03/22/with-utility-styles-your-css-stops-growing |
|
When working with traditional CSS, the first thing you do when you need to style a new page or component is to open a stylesheet and start writing new CSS.
Also when editing existing styles, sometimes you'll write new styles to avoid breaking the existing pages in unexpected ways in other parts of the page. This is why I've not seen many projects where the styling is maintained or refactored over time - only added to.
By writing new CSS for every new page or component, the size of your stylesheets will continue to grow and be less performant and harder to maintain over time.
With utility styles and frameworks like Tailwind CSS, this happens a lot less or sometimes not at all.
If you need to use a class like flex
or grid
and you already use that in your project, there's no new CSS to add and the stylesheet doesn't grow. Because these type of classes are so specific, they're much more reusable which means less duplication of CSS rules and less CSS in total.