dkjain
dkjain

Reputation: 881

SCSS: Calling a mixin inside another mixin?

In the code below, I am trying to DRYing out SCSS by calling another SCSS/SASS mixin padding-all() inside mybtn-structure() mixin but SCSS wouldn't allow this and throws up errors.

@mixin padding-all($top: null, $right: null, $bottom: null, 
$left: null, $all: null) { 
         padding-top: $top;
         padding-right: $right; 
         padding-bottom: $bottom; 
         padding-left: $left; 
         padding: $all; }


@mixin mybtn-structure ($padding: null, $margin: 15px ) {
  padding: @include padding-all($padding);
  margin: $margin;
}

.cool-btn {
  @include mybtn-structure($padding: 12px, $margin: 10px)
}

I presume there must be a way to get what I am trying to do here. How can a mixin be called inside another mixin?

thanks

Upvotes: 0

Views: 2145

Answers (1)

raxerz
raxerz

Reputation: 576

Try removing the padding attribute in mybtn-structure mixin and call the mixin as follows:

@mixin mybtn-structure ($padding: null, $margin: 15px ) {
  @include padding-all($padding);
  margin: $margin;
}

Upvotes: 2

Related Questions