0

In Sass we can use argument list but how can we check if this argList is empty or not?

Here a basic sample with some debugs :

@mixin mymixin($myargs...) {
    @debug $myargs;
    @debug type-of($transitions);
    @debug not $myargs;
    @debug $myargs == ();
    @debug $myargs == list;
    @debug $myargs == arglist;
    @debug $myargs == "";
    @debug $myargs == false;
    @debug $myargs == null;
    @debug $myargs == (null);
    @debug $myargs == [];
    @debug $myargs == array;
}
html {
    @include mymixin();
}

returns :

Debug: ()
Debug: arglist
Debug: false
Debug: false
Debug: false
Debug: false
Debug: false
Debug: false
Debug: false
Debug: false
Debug: false
Debug: false
Klemart3D
  • 180
  • 9

1 Answers1

2

Length of lists can be achieved by using the length method of SASS. if length($myargs) is zero, it means the list is empty. More information about length: https://sass-lang.com/documentation/modules/list#length

@mixin mymixin($myargs...) {
    @debug length($myargs) == 0;
}
html {
    @include mymixin();
}
Amirreza Noori
  • 1,456
  • 1
  • 6
  • 20