Skip to content

Instantly share code, notes, and snippets.

@adamwathan
Created August 10, 2017 15:47
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 adamwathan/f5159900a02ef1c59ae3e7577f419101 to your computer and use it in GitHub Desktop.
Save adamwathan/f5159900a02ef1c59ae3e7577f419101 to your computer and use it in GitHub Desktop.

Instead, use mixins. This is really easy in Less because any class can already be used as a mixin, but if you are using Sass, I would extract a mixin from a utility as soon as I wanted to reuse it, and use that mixin in both the component and the original utility, like:

@mixin rounded-lg() {
  border-radius 8px;
}

.card {
  @include rounded-lg();
}

.rounded-lg {
  @include rounded-lg();
}

Again in Less this is a little easier, which is the biggest reason I still use it over Sass:

.card {
  .rounded-lg;
}

.rounded-lg {
  border-radius 8px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment