Cross-browser custom scrollbar styling using standardized scrollbar-color and webkit rules
A bulky default operating system scrollbar can ruin the tailored ambiance of a dark-mode web application. Combining standard W3C scrollbar-color and scrollbar-width with webkit pseudo-elements achieves a sleek, consistent track across Chrome, Safari, and Firefox.
How to Use the Custom Scrollbar (3 Simple Steps)
Pick Your Track & Thumb Style
Choose scrollbar width, track background colour, thumb colour and border-radius. Toggle the thumb border option for an outlined look, and select a preset to jump-start your design.
Configure Hover & Motion
Pick a hover effect (colour change, grow, opacity fade, or none) and dial in a transition duration. Set whether styles apply to the whole page or a scoped container element class.
Copy the Cross-Browser CSS
The CSS tab delivers both the modern scrollbar-color block and the full ::-webkit-scrollbar rules. Download the self-contained HTML demo, or export your design as a reloadable JSON config.
Features & CSS Best Practices
Dual-Standard Output
Generates both the W3C Scrollbars Specification properties (scrollbar-width, scrollbar-color) and the WebKit pseudo-element approach (::-webkit-scrollbar), covering Firefox, Chrome, Edge, and Safari in a single stylesheet.
Touch-Safe Hover Media Query
Hover colour-change transitions are wrapped in @media (hover: hover), preventing thumb colour from getting permanently stuck on touch-screen devices that do not support true hover states.
Element Scoping
Target a specific container class instead of the whole page — ideal for styled code blocks, chat message lists, horizontal carousels, or any overflow container that needs branded scrollbars without affecting global page scroll.
Reduced-Motion Respect
When a transition duration is set, the generated CSS automatically appends an @media (prefers-reduced-motion: reduce) block that disables thumb transitions for users who have requested reduced animation in their OS settings.
Frequently Asked Questions
What is the difference between scrollbar-color and ::-webkit-scrollbar?
scrollbar-color and scrollbar-width are part of the W3C CSS Scrollbars Specification and are supported natively in Firefox (v64+), Chrome (v121+), and Safari (v15.4+ with partial support). ::-webkit-scrollbar is a non-standard WebKit extension supported in all versions of Chrome, Edge, and Safari, but not Firefox. Using both together gives full cross-browser coverage.
Can I set the scrollbar width to an exact pixel value with the modern standard?
Not directly. The scrollbar-width property only accepts the keyword values auto, thin, or none — it does not accept pixel values. For precise width control, use the ::-webkit-scrollbar { width: Npx; } WebKit rule alongside the standard keyword.
Why do my custom scrollbar styles not appear on macOS?
macOS uses overlay scrollbars by default when "Show scroll bars: When scrolling" is selected in System Settings. Overlay scrollbars float above content and are not styled by CSS. To force a traditional scrollbar, set overflow: scroll on the element, or change the system preference to "Always".
How do I scope custom scrollbar styles to a single container instead of the whole page?
Use the "Element target" mode in the generator and enter a CSS class name. The tool will prefix all ::-webkit-scrollbar pseudo-elements with .your-class::-webkit-scrollbar and apply scrollbar-color to .your-class. Add overflow-y: scroll or auto to that element so a scrollbar actually appears.
How do I style scrollbars in Chrome, Edge, and Safari vs Firefox?
Firefox uses the W3C standard properties scrollbar-width: thin; and scrollbar-color: var(--thumb) var(--track);. Chromium and WebKit browsers require vendor-prefixed pseudo-elements ::-webkit-scrollbar, ::-webkit-scrollbar-thumb, and ::-webkit-scrollbar-track.
Can I hide scrollbars completely while still allowing page scrolling?
Yes. Apply scrollbar-width: none; for Firefox and ::-webkit-scrollbar { display: none; } for Chrome/Safari. Content remains fully scrollable via mouse wheel, trackpad gestures, and keyboard arrows.
How do I create rounded pill scrollbar thumbs in CSS?
In the ::-webkit-scrollbar-thumb selector, set border-radius: 9999px; and add a transparent border (e.g. border: 3px solid transparent; background-clip: padding-box;) to create comfortable inset padding around the thumb.
CSS Scrollbar Styling: Modern Standard, WebKit Pseudo-Elements, and Cross-Browser Strategy
Scrollbars are one of the most recognisable UI chrome elements on the web, yet for decades CSS offered no standardised way to style them. The WebKit browser engine introduced the proprietary ::-webkit-scrollbar family of pseudo-elements in 2009, allowing Chrome and Safari developers to restyle track, thumb, corner, and button areas in granular detail.
In 2018, the W3C published the CSS Scrollbars Specification (Level 1), introducing two new properties: scrollbar-width (which accepts auto, thin, or none) and scrollbar-color (which accepts two colour values — thumb first, then track). Firefox shipped these properties in version 64. Chrome and Edge added support in version 121 (January 2024). As of 2025, both approaches can be used in a single stylesheet.
When designing scrollbars, consider accessibility from the outset. Maintain at least 3:1 contrast between the thumb and track (WCAG 2.1 success criterion 1.4.11). Never use scrollbar-width: none without providing an alternative navigation mechanism — invisible scrollbars are a significant usability hazard for keyboard and low-vision users.
/* Modern Standard (Firefox 64+, Chrome 121+, Safari 15.4+) */
html {
scrollbar-width: thin;
scrollbar-color: #6366f1 #1e293b;
}
/* WebKit Vendor Prefix (Chrome, Edge, Safari all versions) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #1e293b; border-radius: 8px; }
::-webkit-scrollbar-thumb {
background-color: #6366f1;
border-radius: 8px;
min-height: 40px;
transition: background-color 200ms ease;
}
@media (hover: hover) {
::-webkit-scrollbar-thumb:hover { background-color: #818cf8; }
}
::-webkit-scrollbar-thumb:active { background-color: #4f46e5; }
@media (prefers-reduced-motion: reduce) {
::-webkit-scrollbar-thumb { transition: none; }
}
.scrollable {
overflow-y: scroll;
max-height: 400px;
scrollbar-width: thin;
scrollbar-color: #38bdf8 #1e293b;
}
.scrollable::-webkit-scrollbar { width: 8px; }
.scrollable::-webkit-scrollbar-track { background: #1e293b; border-radius: 6px; }
.scrollable::-webkit-scrollbar-thumb { background-color: #38bdf8; border-radius: 6px; }
@media (hover: hover) {
.scrollable::-webkit-scrollbar-thumb:hover { background-color: #7dd3fc; }
}
Browser Compatibility & Standards Support
Verified across modern desktop and mobile browser engines according to W3C specifications.
| Feature | Chrome | Firefox | Safari | Edge |
|---|---|---|---|---|
| scrollbar-color | ✓ 121+ (Supported) | ✓ 64+ (Supported) | ✓ 15.4+ (Supported) | ✓ 121+ (Supported) |
| scrollbar-width | ✓ 121+ (Supported) | ✓ 64+ (Supported) | ✓ 15.4+ (Supported) | ✓ 121+ (Supported) |
| ::-webkit-scrollbar | ✓ All versions (Supported) | Not supported | ✓ All versions (Supported) | ✓ All versions (Supported) |
| Hover media query guard | ✓ Universal (Full) | ✓ Universal (Full) | ✓ Universal (Full) | ✓ Universal (Full) |
| prefers-reduced-motion | ✓ Production Ready | ✓ Production Ready | ✓ Production Ready | ✓ Production Ready |
Architecture Best Practices & Production Tips
💡 Force Traditional Scrollbars on macOS for Testing
By default macOS uses overlay scrollbars that disappear when not in use and cannot be styled by CSS. During development, go to System Settings ? Appearance ? Show scroll bars ? Always to make traditional scrollbars visible and testable in all Chromium/WebKit browsers.
💡 Use overflow: scroll Rather Than overflow: auto When Styling
overflow: auto only shows a scrollbar when content overflows, meaning the bar may not be visible during development. Set overflow: scroll on containers you are targeting so the scrollbar is always present while you design. Switch back to auto in production if you do not want a bar on short content.