SCSS Standards
File organisation, code style, and authoring practices that support OOCSS and maintainable stylesheets.
File structure
Writing style
Selectors
Only class and element selectors are used for styling; never ID or attribute selectors.
// Bad – independent rules .media { display: flex; gap: 1rem; } .media-img { flex-shrink: 0; } .media-body { flex: 1; } // Good – nested .media { display: flex; .img { ... } // uses descendant selector }For skins, write standalone rules that apply directly:
Placeholder selectors for objects (optional)
Define structural objects as silent placeholders (%) when you want to share the base structure without emitting an unused class. Extend them in concrete classes.
Prefer this over extending regular classes, because it keeps the compiled CSS clean and avoids unwanted grouping.
Mixins vs @extend
Use mixins for reusable chunks that require parameters (e.g., breakpoint helpers, responsive widths).
For sharing base structural styles statically,
@extendon placeholders is acceptable.Avoid
@extendacross unrelated components – it can cause selector bloat and source‑order surprises.
Variables and design tokens
All values come from CSS custom properties (or SCSS variables). No “magic numbers” or raw colour codes.
Media queries
Place media queries inside the selector they affect, keeping the layout and its responsive behaviour together.
Performance and output
Compile to a flat, single‑class selector CSS. Avoid chains like
.card .card-header– use a single.card-headerclass instead.Skins are applied as additional classes, so they add minimal extra specificity and can be combined freely.
Unused placeholders and skin classes can be easily removed from the output by only importing what is required, keeping the final bundle lean.