Why I spent years trying to make CSS states predictable
The article discusses the challenges of managing CSS states and the complexity that arises when multiple states overlap. It introduces a tool called Tasty, which aims to simplify the process by allowing developers to define component states declaratively. This approach eliminates selector conflicts and makes extending components easier.
- ▪CSS states can become complex when multiple states overlap, leading to conflicts.
- ▪The author developed a tool called Tasty to express component states as a map, simplifying selector logic.
- ▪Tasty compiles state maps into unambiguous selectors, preventing conflicts and easing component extension.
Opening excerpt (first ~120 words) tap to expand
Apr 23, 2026 · 8 min read Why I spent years trying to make CSS states predictable csswebdevfrontenddesignsystem Have you ever changed the order of two CSS rules and broken a component without changing the logic? .btn:hover { background: dodgerblue; } .btn[disabled] { background: gray; } Both selectors have specificity (0, 1, 1). When a button is both hovered and disabled, the browser falls back to source order. If the :hover rule comes last, the disabled button turns blue. If the [disabled] rule comes last, it stays gray. That sounds small, but it points to a bigger problem: component state in CSS often works by overlap. As long as a component has only one or two states, that overlap feels manageable.
…
Excerpt limited to ~120 words for fair-use compliance. The full article is at tenphi.me.