Mohammad Shanaah
Mohammad Shanaah

Reputation: 61

Calling SCSS mixin file using Javascript

I have three files

.. icons.scss --> mixin code

.. main.scss --> here I call the mixin using @include icon(name)

.. main.js

Everything until now is working perfectly as expected. But what if I want to change the value of ,name' in the mixin from inside the JS file..

We all know we have more than one way to manipulate CSS inside JS.

For example: inside my JS I do something like:

document.getElementById("id").style = '@include icon(name2)';

Its not going to work because I think JS is looking for a property and a value, but how to do it? Is there a way?

Upvotes: 0

Views: 2742

Answers (2)

Vladu Ionut
Vladu Ionut

Reputation: 8183

You cannot use SCSS/SASS in JS directly. SASS is just a CSS preprocessor. A CSS preprocessor helps you write maintainable, future-proof code and it will seriously reduce the amount of CSS you have to write.

The SCSS files are compiled into CSS syntax at build time, the browser doesn't know how to interpret SCSS it uses only CSS for styles.

Upvotes: 2

Ponpon32
Ponpon32

Reputation: 2200

i have to downvote your question, it seems like you are not understanding the concept of SCSS/CSS.

Instead of trying to override exists CSS Property, you can try to create different class that point to different icon and just change the class name.

Upvotes: 0

Related Questions