Last active
January 18, 2021 15:31
-
-
Save Alex-D/59fd79bf0d574c6373a7706291614cda to your computer and use it in GitHub Desktop.
Scrollbar SCSS mixin
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
@mixin scrollbars( | |
$size, | |
$foreground-color, | |
$background-color, | |
$border-width: 0, | |
$context-hover-background-color: lighten($foreground-color, 5%), | |
$hover-background-color: lighten($foreground-color, 10%), | |
) { | |
// Blink browsers (Chrome, Edge) | |
&::-webkit-scrollbar { | |
width: $size; | |
height: $size; | |
} | |
&::-webkit-scrollbar-track { | |
background: $background-color; | |
} | |
&::-webkit-scrollbar-thumb { | |
background: $foreground-color; | |
@if $border-width != 0 { | |
border: $border-width solid $background-color; | |
} | |
} | |
&:hover::-webkit-scrollbar-thumb { | |
background: $context-hover-background-color; | |
} | |
&::-webkit-scrollbar-thumb:hover { | |
background: $hover-background-color; | |
} | |
// Firefox | |
& { | |
scrollbar-color: $foreground-color $background-color; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment