1

Is it possible to grab a specific value from a variable? I have been trying to make my variable as a list, but I keep getting errors.

For starters I have an @include(); like so...

@include myMixin (2px 4px 13px 0px);

And then I have a mixin like this...

@mixin($myVar){

}

And from here I have the following variable.. $myVar: $myVar; like so...

@mixin($myVar){
  $myVar:$myVar;

 //when I do this I get an error in my sass watch
 @debug Second value is nth($myVar, 2);

 //This is how I want to use it...
 margin-right:nth($myVar, 2);
}

My Error:

Sass list index is 2 but list is only 1 item long for "nth:

SUMMARY:

This approach doesn't seem to be working so I am thinking maybe there is a different way to do this, I don't want to get into too much detail as there are a lot of other things going on. Basically my end goal is to have a variable equal a set of values and to be able to grab /use a specific values somehow. Any help is much appreciated.. Thanks in advance.

1 Answer 1

1

You have the right idea:

@mixin myMixin($myVar){
    //when I do this I get an error in my sass watch
    @debug Second value is nth($myVar, 2);

    //This is how I want to use it...
    margin-right: nth($myVar, 2);
}
.test {
    @include myMixin(2px 4px 13px 0px);
}

DEBUG: Second value is 4px

.test {
  margin-right: 4px;
}

Is there something else here that you're not showing that is possibly messing this up?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.