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 Add Reusable Logic to Your Sass Advanced Mixins Challenge

How do in mixin square and specify the argument each variable

Where am getting wrong

style.scss
@mixin square ($size , $color: black  ){
height: $size;
width: $size;
border: 1px solid $color;
}
.box{
@include square($size: 50px ,$color: red);
height: $size;
width: $size;
border: $color;

}

2 Answers

Liam Ferb
Liam Ferb
8,454 Points

Okay, so what mixins do is essentially (when compiling) replaces the @include ____ with the code you placed in the mixin, and replaces the variables with the arguments passed in, in other words, mixins don't set the variables, so you can get rid of the properties below @include, or in other words, you should have this:

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

.box {
  @include square(50px, red);
}

Oh and you don't have to specify the variable names unless you are placing them in another order than they appear in the parentheses next to the mixins.

Hope this helps!

Wonderful explanation I really appreciate it. Thanks

Can you explain what exactly you're having problems with? The way you would use this mixin is the following:

.box { @include square(50px, red); }

Am have box class which asked include square mixin and specify variable which am getting a lot problem with