scss-mixins

SCSS error while passing numeric value as arguments


I have the following mixen, inside of it i'm trying to loop based on arguments.

@mixin detCls($s, $e) {
   @for $i from #{$s} through #{$e} {
    // doing some stuffs
    }
  }

@include detCls(16, 24)

But while complying it throws an error

@for $i from #{$s} through #{$e} { 16 is not a number.


Solution

  • You don't need string interpolation #{...}, just use $s , $e.

    @mixin detCls($s, $e) {
       @for $i from $s through $e {
        // doing some stuffs
        }
     }
    
    @include detCls(16, 24)