Last active
April 3, 2020 19:34
-
-
Save davidicus/721e8c90741c88db46fdd9c88fb91e7e to your computer and use it in GitHub Desktop.
Sass mixin for non support fallbacks with custom properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
: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