0

Hi i was trying to apply multiple mixins to a particular class based on width , but that does not working. When we apply mixins individually it works fine is there any way to apply multiple mixins.

@include largeDevice, mediumeDevice {
    width: 600px;
}

the above css is to apply multiple mixins to a class , Whether this is right way.

Applying multiple Mixins (Not Working)

.battery-component svg {
  width: 540px;
  @include largeDevice, mediumeDevice {
    width: 600px;
  }
 @include extraSmallDevice {
    width: 500px;
 } 
}

Applying mixins individually but this is (Working fine)

.battery-component svg {
  width: 540px;
  @include largeDevice {
    width: 600px;
  }
  @include mediumeDevice {
    width: 600px;
  }
 @include extraSmallDevice {
    width: 500px;
 }    
}

Is there any way to apply multiple mixins

custom_mixin.scss

@mixin bottom-panel($maxWidth) {
  width: $maxWidth;
}


$breakpoint-lr: 1200px;
$breakpoint-md: 992px;
$breakpoint-sm: 768px;
$breakpoint-xs: 600px;

@mixin largeDevice {
  @media (min-width: #{$breakpoint-lr}) {
    @content;
  }
}

@mixin mediumDevice {
  @media (min-width: #{$breakpoint-md}) and (max-width: #{$breakpoint-lr - 1px}) {
    @content;
  }
}

@mixin smallDevice {
  @media (min-width: #{$breakpoint-sm}) and (max-width: #{$breakpoint-md - 1px}) {
    @content;
  }
}

@mixin extraSmallDevice {
  @media (min-width: #{$breakpoint-xs}) and (max-width: #{$breakpoint-sm - 1px}) {
    @content;
  }
}
Gopinath Kaliappan
  • 6,929
  • 8
  • 37
  • 60

1 Answers1

-1

Sass does not allow interpolating mixin names, so the only way you can do something close to it is create others mixin grouping another mixins

@mixin largemediumDevice($mixin1-arg1, $mixin2-arg1){
  @include largeDevice($mixin1-arg1){@content}
  @include mediumDevice($mixin2-arg1){@content}
}
SpaceDogCS
  • 2,808
  • 3
  • 20
  • 49