Skip to content

Instantly share code, notes, and snippets.

@CodeRecipez
Last active December 15, 2015 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CodeRecipez/5260845 to your computer and use it in GitHub Desktop.
Save CodeRecipez/5260845 to your computer and use it in GitHub Desktop.
Sass 101 - A newb's guide: mixins w/default arguments

Mixins can also specify default values for their arguments using the normal variable-setting syntax. Then when the mixin is included, if it doesn’t pass in that argument, the default value will be used instead. For example:

mixins_w_default_arguments.scss

SassMeister Gist

@mixin border($radius: 3px, $style: 1px solid red) {
-moz-border-radius: $radius;
-webkit-border-radius: $radius;
border-radius: $radius;
border: $style;
}
.my-new-class {
@include border;
}
.my-other-class {
@include border(3px 3px 0 0, 1px solid orange);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment