Glossary
Glossary Cascade layers

Cascade layers

Also known as: @layer, css layers, cascade layer
TechCSSModern Css

Definition

A CSS feature — @layer base, components, utilities; — that groups rules into named layers with an explicit order, so that a rule in a later layer wins over any rule in an earlier one regardless of specificity; the way to make a reset lose to a component and a component lose to a utility without !important or selector arithmetic

Tailwind v4 is built on it (@layer theme, base, components, utilities), and so is this site’s main.css: the theme files sit in a layer below the utilities, which is why a bg-elevated class always beats a theme rule and a theme rule always beats the reset. Unlayered styles win over every layer, which is the trap — a stray global stylesheet outranks everything until it is put in a layer. For a design system, layers are the cascade made into an architecture: the order of layers is the order of authority, written once.

Tech

Specificity was a heuristic for authority; layers are authority stated. Once the layers are named, a rule’s place in the cascade is a decision, not an accident of how many classes it has.

Related Terms

  • a: Appearance
  • ?: Keyboard shortcuts