Skip to content

Sass Project Structure

A clear folder structure is what keeps a Sass project maintainable as it grows past a handful of files. This lesson covers foundational organization principles before the next lesson introduces the widely used 7-1 pattern in full detail.

What Makes a Good Sass Project Structure?

A good structure groups files by responsibility, tokens and configuration, base/reset styles, components, layout, and pages, rather than dumping everything into one folder or one giant file. Each folder typically has its own barrel _index.scss file forwarding its siblings.

styles/
  abstracts/     // variables, functions, mixins
  base/          // reset, typography defaults
  components/    // buttons, cards, forms
  layout/        // header, footer, grid
  pages/         // page-specific overrides
  main.scss      // entry file, loads everything

This structure scales from small projects (a handful of files per folder) to large ones (dozens of components) without needing a fundamental rework.

A Minimal Structure to Start From

styles/
  _variables.scss
  _mixins.scss
  _reset.scss
  _buttons.scss
  main.scss
  • Start flat for small projects, splitting into folders once a category grows past a handful of files.
  • Keep an obvious entry file (main.scss) that is the only file passed to the compiler.
  • Order matters: variables and mixins must be loaded before the files that use them.
  • Prefer many small, focused partials over a few large, mixed-concern ones.

Sass Project Structure Cheatsheet

Common folder responsibilities in a scalable Sass architecture.

Folder Contains Example Files
abstracts/ Variables, functions, mixins (no CSS output) _colors.scss, _mixins.scss
base/ Resets and global element defaults _reset.scss, _typography.scss
components/ Individual, reusable UI pieces _buttons.scss, _cards.scss
layout/ Page-level structural regions _header.scss, _footer.scss
pages/ Page-specific overrides _home.scss, _checkout.scss
main.scss Entry point, the only file compiled directly n/a

Starting Small and Growing Deliberately

Not every project needs the full 7-1 pattern from day one. A small project can start with a flat set of partials and graduate into folders once any single category, components especially, grows large enough to be hard to scan.

Load Order Still Matters

Even with the module system's namespacing, load order matters for one specific case: a file's !default variables can only be configured with with() on their very first load, so configuration files should generally be loaded, and configured, before anything that consumes them.

// main.scss
@use 'abstracts/tokens' with ($primary: #16a34a);
@use 'components';

Keeping Entry Files Thin

A healthy main.scss mostly contains @use statements for a handful of top-level barrel files, not dozens of individual partials and definitely no actual style rules of its own.

  • If main.scss starts accumulating real declarations, move them into a properly named partial.
  • A quick scan of main.scss should tell you the entire shape of the project's architecture.

Common Mistakes

  • Putting every style in one massive file instead of splitting by responsibility from an early stage.
  • Loading component partials before the abstracts (variables, mixins) they depend on.
  • Letting main.scss accumulate actual style rules instead of staying a thin, @use-only entry point.
  • Adopting a large, complex structure (like the full 7-1 pattern) for a tiny project where it adds more overhead than value.

Key Takeaways

  • Group Sass files by responsibility: abstracts, base, components, layout, and pages.
  • Keep a thin main.scss entry file that primarily contains @use statements.
  • Load configuration and abstracts before anything that depends on them.
  • Start simple and grow into a more elaborate structure only once a project's size justifies it.

Pro Tip

Don't force a large architecture onto a small project, start with a flat set of well-named partials, and only introduce folders and barrel files once a single category genuinely grows past 5-6 files.