Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Why to put “_” in front of filename in SCSS ?

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

When we add “_” in front of the SCSS file, it means that it is partial for SCSS. When the compiler gets any SCSS files starting with “_”, it simply ignores the file. If you want this partial for SCSS to be included for styles, you must use @import. The advantage of using partials is that you can use style files to organize your code and all the files would be compiled on a single file. The purpose of partial SCSS is to keep your styles separated into logical sections.
In the end, we want one SCSS file to have complied whereas we can have many logical partial SCSS files.

Syntax:

@import filename;

Note: While importing we don’t put “_”, just the file name.

Examples 1: Let’s create a colors file _colors.scss




$first-color: blue;
$second-color: yellow;
  
// let's include it in main
// SCSS file, style.scss
  
@import "colors"
body {
  color: $first-color;
  background: $second-color;
}

Output:

body {
  color: blue;
  background: yellow; 
}

Examples 2: Let’s create a colors file _font.scss




$font: arial;
$color: red;
  
// Let's include it in main
// SCSS file, style.scss
  
@import "font";
body {
  font: 100% $font;
  color: $color;
}

Output:

body {
  font: 100% arial;
  color: red;
}
My Personal Notes arrow_drop_up
Last Updated : 28 Nov, 2019
Like Article
Save Article
Similar Reads
Related Tutorials