Skip to content

Instantly share code, notes, and snippets.

@kellysutton
Last active July 27, 2016 18:05
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 kellysutton/e4f849b599df194b5cfbd101e5f7cee8 to your computer and use it in GitHub Desktop.
Save kellysutton/e4f849b599df194b5cfbd101e5f7cee8 to your computer and use it in GitHub Desktop.
Generating Color Utility Classes in SASS
$color-list {
red #f00,
green #0f0,
blue #00f
}
@each $value in $color-list {
.#{nth($value, 1)} {
color: nth($value, 2);
}
.bg-#{nth($value, 1)} {
background-color: nth($value, 2);
}
.border-#{nth($value, 1)} {
border-color: nth($value, 2);
}
}
<h1 class="h1 bold blue sans-serif">Headline</h1>
$white: #fff;
.white {
color: $white;
}
.bg-white {
background-color: $white;
}
.border-white {
border-color: $white;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment