The Best CSS Architecture Starts by Deciding What CSS Should Never Do
Also available in Español The Problem A design token system starts clean. Colors, spacing, type scale all values, all legitimate. Then someone needs a quick way to track whether a modal is open, and a custom property is right there, syntactically identical to every token around it. It gets used. Nobody stops to ask whether it should have been. A stylesheet starts as presentation-only. Then a…
The foundation of a strong CSS architecture begins with defining what the system should not do. A design token system initially includes values such as colors, spacing, and type scale. However, when a custom property is needed to track the state of a modal, it can easily be inserted using syntax identical to the existing tokens.
This decision might seem innocuous at the time, as it follows the path of least resistance. Over time, however, the system accumulates permissions by default, without any explicit restrictions. This lack of exclusions allows the system to be asked to do everything, because nothing within it has the authority to refuse. The principle here is that a boundary is a guarantee, not a limitation.
By deciding in advance what CSS will not become, the system maintains its own domain and prevents the inclusion of state or logic. In the case of the token layer, only values are allowed, not application state, as the system declared it would not become a state holder. This approach creates systems that are defined by what they refuse to do, as much as by what they can do.
The strength of a system lies in the decisions made upfront, the boundaries established to prevent future encroachments.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.