scrollbar-color

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

The scrollbar-color CSS property sets the color of the scrollbar track and thumb.

The track refers to the background of the scrollbar, which is generally fixed regardless of the scrolling position.

The thumb refers to the moving part of the scrollbar, which usually floats on top of the track.

When scrollbar-color value is set on the document's root element, the values are applied to the viewport scrollbars.

Syntax

css
/* Keyword values */
scrollbar-color: auto;

/* <color> values */
scrollbar-color: rebeccapurple green; /* Two valid colors.
The first applies to the thumb of the scrollbar, the second to the track. */

/* Global values */
scrollbar-color: inherit;
scrollbar-color: initial;
scrollbar-color: revert;
scrollbar-color: revert-layer;
scrollbar-color: unset;

Values

<scrollbar-color>

Defines the color of the scrollbar.

auto Default platform rendering for the track portion of the scrollbar, in the absence of any other related scrollbar color properties.
<color> <color> Applies the first color to the scrollbar thumb, the second to the scrollbar track.

Note: @media (forced-colors: active) sets scrollbar-color to auto.

Accessibility

When using scrollbar-color property with specific color values, authors should ensure the specified colors have enough contrast between them. For keyword values, UAs should ensure the colors they use have enough contrast. See Techniques for WCAG 2.0: G183: Using a contrast ratio of 3:1.

Formal definition

Initial valueauto
Applies toscrolling boxes
Inheritedyes
Computed valueas specified
Animation typeby computed value type

Formal syntax

scrollbar-color = 
auto |
<color>{2}

Examples

Coloring overflow scrollbars

CSS

css
.scroller {
  width: 300px;
  height: 100px;
  overflow-y: scroll;
  scrollbar-color: #007 #bada55;
}

HTML

html
<div class="scroller">
  Veggies es bonus vobis, proinde vos postulo essum magis kohlrabi welsh onion
  daikon amaranth tatsoi tomatillo melon azuki bean garlic. Gumbo beet greens
  corn soko endive gumbo gourd. Parsley shallot courgette tatsoi pea sprouts
  fava bean collard greens dandelion okra wakame tomato. Dandelion cucumber
  earthnut pea peanut soko zucchini.
</div>

Result

Specifications

Specification
CSS Scrollbars Styling Module Level 1
# scrollbar-color

Browser compatibility

BCD tables only load in the browser

See also