Foundation
Scrollbar
This foundation gives every scrollbar on the page — the viewport's and those of scrollable components such as menus, sheets and panes — a slim, button-less appearance: an 8px rounded thumb in the theme's outline color role, set in a 2px transparent gutter.
- 8px rounded thumb
- Follows the theme
- Firefox fallback
Scroll me.
The thumb uses the outline colour of the current theme.
There are no arrow buttons.
A 2px transparent gutter surrounds the thumb.
Switch the theme to watch it change.
Vertical
Every scroll container gets the slim scrollbar; no class is needed. Make a scrollable region focusable so keyboard users can scroll it.
Mercury
Venus
Earth
Mars
Jupiter
Saturn
Uranus
Neptune
Horizontal
Theming
Set --md-sys-scrollbar-thumb-color on <html> to change every thumb, or on a scroll container to change it locally.
Primary thumb
This container sets its own thumb colour.
Its descendants inherit it.
Other scrollbars keep the theme's outline colour.
Keep scrolling.
Almost there.
The end.
Native rendering
Setting the standard scrollbar-width or scrollbar-color property on an element switches its scrollbar back to the browser's native rendering in Chromium.
Use it to opt a single container out.
Keep scrolling.
The end.
Compatibility
Chromium and Safari render the styled scrollbar through the ::-webkit-scrollbar pseudo-elements. Firefox, which lacks them, gets the closest standard equivalent: scrollbar-width: thin with the same thumb colour through scrollbar-color. Because Firefox resolves that colour on <html> and <body>, a local --md-sys-scrollbar-thumb-color does not reach it there; set scrollbar-color on the container instead. Browsers that support neither show their default scrollbars.