Skip to content

Scrollbar

Scrollbar gutter and width utility styles with module mixins for responsive modifiers.

Utilities (anchor)

Scrollbar utilities and property values
Utility class Property values
.scroll-gutter-auto scrollbar-gutter: auto
.scroll-gutter-stable scrollbar-gutter: stable
.scroll-gutter-stable-edges scrollbar-gutter: stable both-edges
.scroll-gutter-initial scrollbar-gutter: initial
.scroll-width-auto scrollbar-width: auto
.scroll-width-thin scrollbar-width: thin
.scroll-width-initial scrollbar-width: initial
.scroll-color scrollbar-color: var(--scroll-thumb, initial) var(--scroll-track, initial)
.scroll-color-initial scrollbar-color: initial

Responsive mixins (anchor)

Responsive modifier mixins are provided to include where required in custom breakpoints, the utilities available use the following modifier class naming convention:

.scrollbar-stable-auto
.scrollbar-stable-auto-xxl
.scrollbar-stable-auto-xl
.scrollbar-stable-auto-lg
.scrollbar-stable-auto-md
.scrollbar-stable-auto-sm
.scrollbar-stable-auto-xs
.scrollbar-stable-auto-xxs

Using the module (anchor)

Load StyleMods as demonstrated (change file path as required) then include the Sass mixin anywhere below.

custom.scss
@use "stylemods/scss" as *;
@include scrollbar-gutter-css;
@include scrollbar-width-css;
@include scrollbar-color-css;

// Example breakpoint
@media (width < 480px) {
  @include scrollbar-gutter-sm-css;
  @include scrollbar-width-sm-css;
  @include scrollbar-color-sm-css;
}

All can also be included grouped together using a single mixin:

custom.scss
@use "stylemods/scss" as *;
@include scrollbars-css;

// Example breakpoint
@media (width < 480px) {
  @include scrollbars-sm-css;
}

See the using modules page for more information.

Using the framework (anchor)

Using the recommended custom setup enable the styles (and required breakpoints) in an overrides document:

overrides.scss
@use "stylemods/scss/configuration" as *;
$enable-scrollbars:      true;
$enable-scrollbars-sm:   true;

Include the overrides and the framework styles with your custom document for compiling the framework:

custom.scss
@use "overrides";
@use "stylemods/scss/stylemods";

See using the framework for more information.

Source code (anchor)

The Scrollbar source file is included with the layout module files, you can view the source code from the latest release (v1.5.0) via the Github link below.

Source document
stylemods/scss/layout/scrollbar.scss
View on Github
https://github.com/pmbrown/StyleMods/blob/main/scss/layout/scrollbar.scss

Shared documentation about how to customize the default property values for the styles using the Sass and CSS variables is provided on the customizing page.