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 How to check if radio button is checked or not using JavaScript? #2 How to add Read More Read Less Button using JavaScript? #3 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #4 How to uninstall Cocoapods from the Mac OS? #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to Use SQL MAX() Function with Dates?

Recently Posted

#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 #Jan 14 How to display a student’s individual transcript in Colleague? #Jan 11 How to install PuTTY on a MacOS?
You might also like these
WP_Query Class in WordPressWordPressrandom function in SCSS (Sass)SCSSThe * arithmetic operator in Envision BasicEnvision BasicHow to check if the element exists using JavaScript and jQuery?JavaScriptHow to convert an HTML radio buttons into a toggle switch using CSS?CSSAdvanced Array Methods in JavaScript (with examples)JavaScript