Cascade Layers
How Coralite uses native CSS @layer to eliminate specificity wars and allow utility classes to easily override component styles.
The Specificity Problem
In traditional CSS, if a component defines `.btn { padding: 16px; }` and a developer tries to override it with a utility class `
Enter @layer
Coralite wraps all component styles inside the components layer. Unlayered CSS (like your global utility classes) always takes precedence over layered CSS, regardless of specificity.
@layer components {
.btn {
padding: 16px;
background: var(--accent-violet);
}
}
/* Unlayered CSS wins */
.mt-0 {
padding: 0 ;
/* Actually, no !important needed! */
padding: 0;
}
Visual Proof
Here is a styled button inside the components layer, and a utility class overriding its padding. Notice how the utility class wins without any `!important`.
Why this matters
It means you can ship a component library without worrying about specificity conflicts. Consumers of your components can always override styles using standard CSS classes or inline styles without fighting the cascade.