Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants