Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Composing Global Classes in CSS Modules from SCSS

How do I compose from a global class in CSS Modules, when writing in SCSS?

According to (my understanding of) CSS Module's Composing from global class names documentation, the following should work:

:global {
  .bar {
    color: purple;
  }
}

.my-icon {
  composes: bar from global;
}

But I receive the following error:

referenced class name "bar" in composes not found

How can I change the above to properly compose from a global class?

like image 982
Nicholas Pappas Avatar asked Mar 06 '26 08:03

Nicholas Pappas


1 Answers

You can do it this way:

:global(.bar) {
  color: red;
}

.myIcon {
  composes: bar from global;
}

Here is a link to a sandbox I created with a working example

enter image description here

enter image description here

like image 110
Rasha Essam Avatar answered Mar 08 '26 22:03

Rasha Essam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!