Skip to content

Instantly share code, notes, and snippets.

@maninak
Created December 8, 2021 19:40
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 maninak/d455166ac4f5b4ea5dd32d7ffb76b4ff to your computer and use it in GitHub Desktop.
Save maninak/d455166ac4f5b4ea5dd32d7ffb76b4ff to your computer and use it in GitHub Desktop.
A handy SASS mixin allowing using one-off color classes and @apply from Tailwind CSS the familiar way without needing to add them in the global config.
@tailwind base;
@mixin tw-base-layer-wrap {
@layer base {
@content;
}
@content;
}
@mixin tw-color-classes($cname, $color) {
@include tw-base-layer-wrap {
.text-#{$cname} {
color: #{$color};
}
.bg-#{$cname} {
background-color: #{$color};
}
.border-#{$cname} {
border-color: #{$color};
}
}
}
// @use '../assets/css/utils' as utils;
// @include utils.tw-color-classes('investment-ideas-light', #f1e9d8);
// @include utils.tw-color-classes('investment-ideas-dark', #31434a);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment