I would like to keep my sass code short.
instead of
@mixin tg($font-size,$line-height) {
something related to font-size and line-height
}
@mixin h1 {
@include tg
}
@mixin h2 {
@include tg
}
....
How can i create a @mixin lib with loop?
$typography-list: h1, h2......
@mixin tg($font-size,$line-height) {
something related to font-size and line-height
}
@each $typography in $typography-list {
create @mixin {
@include tg()
}
}
if so, what is the best way of doing it?
In essence, you are referring to SCSS
producing SCSS
. This is called as meta-programming. It is not possible in SASS
. Unless SASS invents some technique or you have another language that compiles to SCSS
.
In short, currently, you cannot do that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With