π¨ CSS scrollbar-color β Complete Tutorial
The CSS scrollbar-color property allows you to style thethumb and track colors of a scrollbar β but only in Firefox. This is great for matching your UI theme, improving accessibility, or creating a more modern, minimal interface.
>>βWith scrollbar-color, Firefox scrollbars become theme-aware and much more elegant.β
Note
β Firefox-only feature
β Controls scrollbar thumb & track
β Use alongside scrollbar-width for full styling
β Controls scrollbar thumb & track
β Use alongside scrollbar-width for full styling
π¦ Syntax
scrollbar-color syntax
scrollbar-color: <thumb-color> <track-color>;| Value | Description |
|---|---|
| auto | Default system scrollbar colors |
| <color> <color> | Custom thumb & track colors |
π¨ 1. Basic Example
Basic styling
.scroll-box {
overflow-y: scroll;
scrollbar-color: #555 #ccc; /* thumb | track */
}A dark thumb on a light track β simple and readable.
π¨ 2. Dark Mode Style
Dark mode
.dark-scroll {
overflow: auto;
scrollbar-color: #888 #222;
}Perfect for dark-themed dashboards.
π¨ 3. Transparent Track + Colored Thumb
Minimal scrollbar
.minimal {
scrollbar-color: #3498db transparent;
}π¨ 4. Pair with scrollbar-width
thin styled scrollbar
.styled {
scrollbar-width: thin;
scrollbar-color: #4a4a4a #e0e0e0;
}π 5. Applying to HTML or Body
Global scrollbar style
html {
scrollbar-color: #666 #ddd;
scrollbar-width: thin;
}Styles scrollbars across the entire page (Firefox only).
π§ͺ Real-World Use Cases
1οΈβ£ Chat Apps
Chat scroll
.chat-window {
scrollbar-color: #777 #2c2c2c;
}2οΈβ£ Code Editors
Code editor
.editor {
scrollbar-color: #444 #1a1a1a;
}3οΈβ£ Minimal Dashboard Panels
Dashboard panel
.panel {
scrollbar-color: #999 #f5f5f5;
}π Cross-Browser Styling
Because scrollbar-color works only in Firefox, use WebKit scrollbars for Chrome/Edge/Safari:
WebKit scrollbar
.scroll-box::-webkit-scrollbar {
width: 8px;
}
.scroll-box::-webkit-scrollbar-thumb {
background: #555;
}
.scroll-box::-webkit-scrollbar-track {
background: #ccc;
}Note
Combine Firefox + WebKit styling for full support.
β οΈ Common Mistakes
- β Expecting this property to work in Chrome or Safari
- β Forgetting to set overflow to create a scrollable box
- β Using overly low contrast colors, harming accessibility
Note
Always ensure the thumb color contrasts with the track for visibility.
π₯ Summary
scrollbar-color offers a simple way to theme scrollbars in Firefox. When combined with scrollbar-width and WebKit scrollbar styling, you can build modern, elegant, and accessible scrolling experiences across browsers.
>>βCustom scrollbars make your UI look polished and thoughtfully designed.β