CSS Reference ยท Scrolling, Interaction and UI
The scrollbar-color property
Reference for the CSS scrollbar-color property: set the thumb and track colors of scrollbars with a standard property, plus live examples and usage notes.
The scrollbar-color property sets the colors of a scrollbar with two values: the thumb (the part you drag) first, then the track (the groove behind it). It is the standard replacement for the old vendor-specific ::-webkit-scrollbar pseudo-elements when all you need is colors.
The browser still draws the scrollbar itself, so the shape and the buttons stay native. That keeps the scrollbar familiar and usable.
.panel { scrollbar-color: #2563eb #e2e8f0; }
Try it
Some systems use overlay scrollbars that only appear while scrolling, so the colors may seem less obvious there.
Syntax
scrollbar-color: auto | <thumb-color> <track-color>;
- Initial value:
auto - Applies to: scroll containers
- Inherited: yes
- Animatable: yes, as colors
- Computed value:
autoor two computed colors
Values
| Value | Description |
|---|---|
auto |
The platform's default scrollbar colors, which also follow the user's light or dark system theme. |
<color> <color> |
Thumb color, then track color. Both must be given. Any CSS color works, including semi-transparent ones. |
Usage notes
- Because it is inherited, set it once on
htmlto color the page scrollbar and every scrollbar inside it. - Keep enough contrast between thumb and track so the control remains easy to see; WCAG asks for a non-text contrast of 3:1 for essential interface parts.
- It does not change the width. Use
scrollbar-widthfor that. - A custom value replaces the system's own colors, including its light and dark adaptation, so test it in both themes.
- Avoid mixing it with
::-webkit-scrollbarrules on the same element: browsers that support both handle the combination differently, so pick one approach.
Browser support
Supported in the current versions of the major browsers; check a compatibility table if you must support older releases, which will just show the default scrollbar.
Related
scrollbar-widthโ thicknessscrollbar-gutterโ reserved spaceoverflowโ makes a scrollbar appear- Lesson: Overflow