Skip to content

Instantly share code, notes, and snippets.

@tomas-wrobel
Last active April 16, 2022 20:14
Show Gist options
  • Save tomas-wrobel/20dbed89aaa3e24a4331a58fec479aba to your computer and use it in GitHub Desktop.
Save tomas-wrobel/20dbed89aaa3e24a4331a58fec479aba to your computer and use it in GitHub Desktop.
(Firefox only) SVG gradients set up via SASS
@function svg-gradient($type, $transform, $colors...) {
$stops: "";
@each $color, $offset in $colors {
$stops: $stops + "<stop offset='#{$offset}' stop-color='#{$color}' />";
}
@return url(
"data:image/svg+xml;utf8,\
<svg xmlns='http://www.w3.org/2000/svg'> \
<#{$type}Gradient id='grad' style='gradient-transform: #{$transform};'> \
#{$stops} \
</#{$type}Gradient> \
</svg>"
+ "#grad"
);
}
circle {
fill: svg-gradient(linear, rotate(90deg), black 0%, grey 50%, white 100%)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment