Partial files help organize your styles into smaller pieces. The underscore prefix tells Sass not to create a separate CSS file for that part.
Partial files with underscore prefix in SASS
// Filename: _partial.scss // Use underscore at the start of the filename // Import in main file without underscore @use 'partial';
The underscore (_) at the start means Sass treats it as a partial file.
You do not compile partial files directly; instead, you import them into main files.
// _colors.scss $primary-color: #3498db;
// _buttons.scss @use 'colors'; .button { background-color: colors.$primary-color; color: white; padding: 1rem; }
// main.scss @use 'colors'; @use 'buttons';
This example shows two partial files: one for colors and one for button styles. The main file imports both. Sass compiles all styles into one CSS file without creating separate CSS files for the partials.
// _colors.scss $primary-color: #3498db; // _buttons.scss @use 'colors'; .button { background-color: colors.$primary-color; color: white; padding: 1rem; border-radius: 0.5rem; } // main.scss @use 'colors'; @use 'buttons';
Always start partial filenames with an underscore (_) to mark them as partials.
Partial files are not compiled alone; they must be imported into a main Sass file.
Use @use or @import (deprecated) to include partials in your main file.
Partial files start with an underscore to avoid generating separate CSS files.
They help organize and reuse styles efficiently.
Import partials into main Sass files to compile all styles together.