Order Matters

In large projects, styles often conflict. Cascade Layers allow grouping CSS into layers and explicitly specifying which layer is more important, regardless of selectors.

How It Works:

You create layers at the beginning of the file:

@layer reset, base, components, utilities;

@layer components {
  .button { background: blue; } /* Components layer */
}

@layer utilities {
  .bg-red { background: red; } /* Utilities will always defeat components */
}
Important

Even if button in components layer has very complex selector (#id .class), simple property from utilities layer will override it because utilities layer is declared later.

Tip

This solves the " specificity war " problem and allows forgetting about using !important.