Yogesh Chauhan's Blog

Configuring Modules with @forward rule in SCSS (Sass)

in SCSS on June 3, 2021

Configuring modules with @forward rule is similar to configuring modules with @use rule.

The difference is that you can use the !default flag in it’s configuration while configuring with @forward module.

That is very handy since you can use the other modules members with no values can have default values and if they have values then you can use that value.

For e.g. let’s say you have a _fonts.scss file with the following styles:

// _fonts.scss
$black: #000 !default;

.arial {
  color: $black;

Let’s forward that stylesheet into another one.

// _fonts_adjusted.scss
@forward 'fonts' with (
  $black: #222 !default,

Finally, let’s use it in the main stylesheet.

// main.scss
@use 'fonts_adjusted' with ($black: #333);

This is how it’ll compile into CSS at the end:

// main.scss
.arial {
  color: #333;

Most Read

#1 Solution to the error “Visual Studio Code can’t be opened because Apple cannot check it for malicious software” #2 How to add Read More Read Less Button using JavaScript? #3 How to check if radio button is checked or not using JavaScript? #4 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #5 How to uninstall Cocoapods from the Mac OS? #6 PHP Login System using PDO Part 1: Create User Registration Page

Recently Posted

#Apr 8 JSON.stringify() in JavaScript #Apr 7 Middleware in NextJS #Jan 17 4 advanced ways to search Colleague #Jan 16 Colleague UI Basics: The Search Area #Jan 16 Colleague UI Basics: The Context Area #Jan 16 Colleague UI Basics: Accessing the user interface
You might also like these
How to test the WordPress 5.9 Beta 4?WordPressCasting in PostgreSQLPostgresFETCH clause in PostgreSQLPostgresReview an intentionally vulnerable plugin in WordPressWordPressHow to uninstall Cocoapods from the Mac OS?Miscellaneousclip and clip-path properties in CSSCSSHow to Use the EXISTS and NOT EXISTS Operator with a Subquery in SQL and MySQL?SQL/MySQLWill SQL (Relational) Database become obsolete?SQL/MySQLHow to create a simple tab interaction using CSS?CSSHow to create a full screen loader using CSS and JavaScript?CSSWhat’s a repository on Github?MiscellaneousOpen Source Security Tools for Defense SecurityMiscellaneous