Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS Sass Basics (retired) Advanced Sass Concepts Advanced Mixin Arguments

Sass Advanced Mixin Arguments

Hi I was struggling with the final Sass code challenge and after two days I figured it out. Hope this helps if you're having trouble. Code challange link

@mixin square($size, $color: black) {
  border: $color;
  border: 1px solid $color;
  width: $size;
  height: $size;
}

@mixin rainbow($colors...){ 
    @each $color in $colors{ 
        .#{$color} { 
            background: #{$color}; /* My problem was on this line*/  
        } 
    } 
}
@include rainbow(red, blue, green, yellow);

.box {
    @include square($color: red, $size: 10px)

}

This code allowed me to pass.

Alan Fidelino
Alan Fidelino
12,846 Points

Thanks. Actually, I was about to look into your answer but had a change of heart. I passed 5 out of 6 challenges without any problems to my surprise, lol. I was a bit stuck on the last challenge, then I had to re-read the question and voila, it was so easy. I just need to pass the arguments to the mixin.