Skip to content

Instantly share code, notes, and snippets.

@davidicus
Last active April 3, 2020 19:34
Show Gist options
  • Save davidicus/721e8c90741c88db46fdd9c88fb91e7e to your computer and use it in GitHub Desktop.
Save davidicus/721e8c90741c88db46fdd9c88fb91e7e to your computer and use it in GitHub Desktop.
Sass mixin for non support fallbacks with custom properties
:root {
--foo: green;
}
$ui-01: #555;
@mixin customProp($property, $css-value, $fallback-value) {
#{$property}: $fallback-value;
#{$property}: var(#{$css-value});
}
.button {
@include customProp(color, --foo, $ui-01);
}
// CSS output with support
.button {
color: green;
}
// without support
.button {
color: #555;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment