π CSS scrollbar-width β Complete Tutorial
The CSS scrollbar-width property controls the thickness of scrollbars in Firefox. This property is currently **Firefox-only** and has no effect in Chrome, Edge, or Safari. It is useful when building minimal UIs, chat layouts, dashboards, or custom scrolling components.
>>βscrollbar-width lets you create slimmer, cleaner scrollbars β but only in Firefox.β
Note
β Works ONLY in Firefox
β Controls scrollbar thickness
β Use with ::-webkit-scrollbar for cross-browser support
β Controls scrollbar thickness
β Use with ::-webkit-scrollbar for cross-browser support
π¦ Syntax
scrollbar-width syntax
scrollbar-width: auto | thin | none;| Value | Description |
|---|---|
| auto | Default scrollbar width |
| thin | Displays a small/thin scrollbar |
| none | Hides scrollbar while keeping scroll functionality |
π¨ 1. Make Scrollbar Thin
thin scrollbar
.box {
overflow-y: scroll;
scrollbar-width: thin;
}Common for chat apps, tables, and dashboards.
π¨ 2. Hide Scrollbar Completely
hide scrollbar
.hidden-scroll {
overflow-y: scroll;
scrollbar-width: none; /* Only hides in Firefox */
}Note
Users can still scroll β the scrollbar is just not visible.
π¨ 3. Default Behavior
default
.normal {
scrollbar-width: auto;
}π¨ 4. Combine with scrollbar-color
Firefox also supports scrollbar-color for styling track & thumb.
scrollbar-color
.styled-scroll {
scrollbar-width: thin;
scrollbar-color: #555 #ddd; /* thumb track */
}π Cross-Browser Support Tip
Since scrollbar-width works only in Firefox, you must use WebKit pseudo-elements for Chrome / Edge / Safari.
WebKit scrollbar styling
.styled-scroll::-webkit-scrollbar {
width: 6px;
}
.styled-scroll::-webkit-scrollbar-thumb {
background: #555;
}
.styled-scroll::-webkit-scrollbar-track {
background: #ddd;
}Note
Combine both approaches for full browser support.
π§ͺ Real-World Use Cases
1οΈβ£ Chat Applications
chat
.chat-box {
overflow-y: scroll;
scrollbar-width: thin;
}2οΈβ£ Tables / Data Grids
table scroll
.table-container {
overflow: auto;
scrollbar-width: thin;
}3οΈβ£ Minimal UI Panels
dashboard panel
.panel {
overflow-y: auto;
scrollbar-width: none;
}β οΈ Common Mistakes
- β Expecting it to work in Chrome or Safari (Firefox only!)
- β Setting scrollbar-width on elements without overflow
- β Using none without ensuring users can still scroll
Note
Add padding or visual hints so users know scrolling is possible when hiding scrollbars.
π₯ Summary
scrollbar-width provides a simple, Firefox-only way to control scrollbar thickness. Paired with scrollbar-color and WebKit scrollbar styling, it enables fully customized scrollbars across browsers.
>>βscrollbar-width makes scrollbars minimal, elegant, and unobtrusive.β