Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS

Urmilla Kannuswamy
Urmilla Kannuswamy
1,146 Points

Error while writing mixin for common text pattern

@mixin text { @mixin text($size, $l-height:null, $weight:null, $color:null) { font-size : $size; line-height : $l-height; font-weight : $weight; color : $color;
} }

I wrote this mixin and included the '_mixin.scss' file in the '_base.scss' file. @include text(1em, 1.5, $color:$color-text-base);

I got an error: Mixins may not be defined within control directives or other mixins.

Am i missing something?

1 Answer

David Bath
David Bath
25,939 Points

It looks like a syntax error because you have @mixin text inside @mixin text. You define a mixin like this:

@mixin text($size, $l-height:null, $weight:null, $color:null) {

}

Remove the outer @mixin text and you should be fine.