LogoModulateCSS

Structure

CSS Layer System

The CSS @layer system in ModulateCSS is strategically designed to manage complexity in large-scale web projects by organizing CSS rules into structured and logical layers.

This methodology not only enhances scalability but also improves maintainability across the stylesheet. To make life easy for developers, the layer system aligns with the file structure and naming conventions.

Here is an example of how CSS layers, file names and CSS class names align in a MOdulateCSS project:

CSS @layerFile nameCSS class name
basemodulate.css
typographytypography-standard.csstypography-standard
typography-blog.csstypography-blog
......
primitiveprimitive-button.cssbutton
primitive-form.cssform
......
pagepage-website.csspage-website
page-landing.csspage-landing
page-blog.csspage-blog
......
modulesection-common-header.css
section-common-footer.csssection-common-footer
section-common-image-beside-text.csssection-common-image-beside-text
section-website-benefits.csssection-website-benefits
......
widgetwidget-card-person.csswidget-card-person
widget-card-person.csswidget-card-person
widget-card-product.csswidget-card-product
widget-weather.csswidget-weather
......
themetheme.css

Detailed Explanation of Layers

The layer order is as follows. It is defined in modulate.css itself and has not to be defined again anywhere else.

modulate.css
@layer base, typography, primitive, widget, module, page, utility, theme, override;

Base Layer

Typography

Primitive

Widget

Module

Page

Utility

Theme

Override

Advantages of Using @layer in CSS

Conclusion

By adopting the @layer system, ModulateCSS provides a powerful framework for structuring CSS in a way that promotes maintainability and scalability. This system is instrumental in creating well-organized stylesheets that are easier to manage and update, supporting robust web development practices.