Skip to content

Instantly share code, notes, and snippets.

@haggen
Last active April 26, 2023 05:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haggen/4649531d084f56fd877e to your computer and use it in GitHub Desktop.
Save haggen/4649531d084f56fd877e to your computer and use it in GitHub Desktop.
Text stroke using text-shadow as SCSS mixin.
/**
* Text stroke using text-shadow.
* @example
* p {
* @include stroke(black, 2px);
* }
*/
@mixin stroke($color, $size: 1px) {
$value: null;
@for $x from $size * -1 through $size {
@for $y from $size * -1 through $size {
@if not ($x == 0px and $y == 0px) {
$value: $value, $x $y $color;
}
}
}
text-shadow: $value;
}
@AndreKelling
Copy link

great mixin!

but my preprocessor says

Error: Expected expression.
  ╷
2 │     $value:;
  │            ^
  ╵

so i went with declaring $value with null

$value: null;

and the size default should have a unit with for visible results:

@mixin stroke($color, $size: 1px) {

@haggen
Copy link
Author

haggen commented Sep 20, 2022

@AndreKelling Thanks! I just edited it with your feedback. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment