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 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #3 How to add Read More Read Less Button using JavaScript? #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

#Aug 15 Is PHP still good for back-end programming? #Aug 10 How to create a multisite network in WordPress? #Aug 3 How to create a circle that follows a cursor using JavaScript and CSS? #Aug 3 How to make a curtain slider using jQuery and CSS? #Aug 2 How to progressively load images and add a blurry placeholder? #Aug 1 How to create a placeholder loader (throbber) using CSS?
You might also like these
The basics of @import rule in SCSS (Sass)SCSSHow to apply style to a specific child element using CSS?CSSWhat is a Strict Requirement in PHP 7 Function Declarations?PHPHow get_template_part helps write reusable code in WordPress?WordPressSubquery in PostgresPostgresCROSS JOIN in PostgresPostgres