Skip to content

Instantly share code, notes, and snippets.

@Alex-D
Last active January 18, 2021 15:31
Show Gist options
  • Save Alex-D/59fd79bf0d574c6373a7706291614cda to your computer and use it in GitHub Desktop.
Save Alex-D/59fd79bf0d574c6373a7706291614cda to your computer and use it in GitHub Desktop.
Scrollbar SCSS mixin
@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