Multiple values for one property with variable argument lists in Sass

You can create a variable outside the loop to “collect” the shadow values, and then use that variable in your text-shadow property. Example:

=stacktextshadow($shadows...)
  $all: ()
  @for $i from 1 through length($shadows)
    $all: append($all, append($i*1px $i*1px 0, nth($shadows, $i)), comma)

  text-shadow: $all

h1
  +stacktextshadow(blue, red, green)

Output:

h1 {
  text-shadow: 1px 1px 0 blue, 2px 2px 0 red, 3px 3px 0 green; }

Leave a Comment