Yogesh Chauhan's Blog

When you don’t want to @forward every member in SCSS (Sass)

in SCSS on May 30, 2021

Quick recap:

What are members in SassScript?

To understand @forward rule, you need to understand the @use rule first.

Here’s another post about @forward rule basics:

@forward rule in SCSS (Sass)

Sometimes, you want to forward the whole module and every function, mixin or variables but other times, you want to keep some members private. Private members can be used by the module or package they are declared in.

@forward show and hide

You can use @forward “” show or @forward “” hide to control members visibility.

For e.g. let’s say we have @mixins in _list.scss module.


// src/_list.scss
$horizontal-list-gap: 2em;

@mixin list-reset {
  margin: 0;
  padding: 0;
  list-style: none;
}

@mixin list-horizontal {
  @include reset;

  li {
    display: inline-block;
    margin: {
      left: -2px;
      right: $horizontal-list-gap;
    }
  }
}


If you want to hide just a handful listed members and forward everything else then use @forward “” hide.

Just like this:


// bootstrap.scss
@forward "src/list" hide list-reset, $horizontal-list-gap;

If you want to hide everything else but just forward handful listed members then use @forward “” show.


// bootstrap.scss
@forward "src/list" show list-reset, $horizontal-list-gap;


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
PHP Variables ScopePHPWhat are Null Sessions?MiscellaneousRelative Length Units in CSSCSSSpecificity of attribute selectorsCSSHow to show slider value in HTML5 range input using JavaScript?HTML12 URLSearchParams methods in JavaScriptJavaScript