CSS scrollbars styling
TheCSS scrollbars styling module defines properties that you can use for visual styling of scrollbars. You can customize the width of the scrollbar as required. You can also customize the color of the scrollbartrack, which is the background of the scrollbar, and the color of the scrollbarthumb, which is the draggable handle of the scrollbar.
In this article
Scrollbar styling in action
This example defines a thin scrollbar with a red thumb and an orange track. To view the thumb, you will need to scroll the text. After the scrollbar is visible, hover over it to see the track.
.poem { width: 300px; height: 100px; border: 1px solid;}css
.poem { overflow: scroll; scrollbar-color: red orange; scrollbar-width: thin;}<blockquote> <h3>A Small Needful Fact</h3> <pre>Is that Eric Garner workedfor some time for the Parks and Rec.Horticultural Department, which means,perhaps, that with his very large hands,perhaps, in all likelihood,he put gently into the earthsome plants which, most likely,some of them, in all likelihood,continue to grow, continueto do what such plants do, like houseand feed small and necessary creatures,like being pleasant to touch and smell,like converting sunlightinto food, like making it easierfor us to breathe.</pre > <p> - <a href="https://onbeing.org/poetry/a-small-needful-fact/">Ross Gay</a> </p></blockquote>Note:When customizing scrollbars, ensure that the thumb and track have enough contrast with the surrounding background. Also ensure that the scrollbar hit area is large enough for people who use touch input.
Reference
>CSS properties
Related concepts
overflow-blockCSS propertyoverflow-inlineCSS propertyoverflow-xCSS propertyoverflow-yCSS propertyoverflowCSS shorthand propertyoverflow-clip-marginCSS propertyscrollbar-gutterCSS propertyscroll-behaviorCSS propertyscroll-marginCSS shorthand propertyscroll-paddingCSS shorthand propertyscroll-snap-alignCSS propertyscroll-snap-stopCSS propertyscroll-snap-typeCSS property::-webkit-scrollbarpseudo-element- scroll container glossary term
scrollbarARIA role
Specifications
| Specification |
|---|
| CSS Scrollbars Styling Module Level 1> |