I have a very simple mixin which looks like this:
@mixin global( $variable-name ) {
font-size: #{$variable-name}-font-size;
}
I have prev
You can't create a dynamic variables in sass.
'#{}' means it will convert whatever attribute to its plain css form, it won't be treated as a variable it will be treated as a text.
What you can do is create a map for the list of properties and call them inside the mixin.
$input-font-size: 16px;
$textarea-font-size: 14px;
$var-map: (
input: $input-font-size,
textarea: $textarea-font-size,
);
@mixin global( $variable-name ) {
font-size: map-get($var-map, $variable-name);
}
body {
@include global( input );
}
or if you dont want to create the map then you can simply pass the variable name in the mixin
@mixin sec( $variable-name ) {
font-size: $variable-name;
}
.text-area {
@include sec( $textarea-font-size );
}
Sample pen https://codepen.io/srajagop/pen/aWedNM