Skip to content
This repository has been archived by the owner on Sep 29, 2024. It is now read-only.

Set properties using mixin #115

Open
sudipto-roy opened this issue Mar 30, 2018 · 1 comment
Open

Set properties using mixin #115

sudipto-roy opened this issue Mar 30, 2018 · 1 comment

Comments

@sudipto-roy
Copy link

sudipto-roy commented Mar 30, 2018

Not able to set property using mixin parameters.

@mixin set-val($property, $value){
  padding: $value; // works
  border: $(value); // works
  $property: 0; // do not work
  $(property): 0; // do not work
}
.class {
  @include set-val(margin, 0);
}
@diverent2
Copy link

Sadly, this is not possible.

Sass/Postcss takes an input and outputs something (compiling).
Just like you can´t dynamically change $vars inside media queries.
Modern browser support this using native css variables--var which can dynamically be changed.
However a preprocessor like sass/postcss can´t do that. Its output will always remain static.

For more info see: https://stackoverflow.com/questions/43192926/use-a-mixins-to-change-variable-value

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants