Standardised Scrollbar Styling and Modern WebKit Architecture
For more than a decade, customising scrollbars in WebKit-based browsers like Apple Safari required proprietary, vendor-prefixed pseudo-elements (such as ::-webkit-scrollbar, ::-webkit-scrollbar-thumb, and ::-webkit-scrollbar-track). While these proprietary selectors provided granular pixel-level control, they broke native macOS overlay scrollbar mechanics, caused layout instability, and conflicted with cross-browser interoperability on non-WebKit rendering engines.
With the release of Safari 17.2 on macOS Sonoma and iOS 17, WebKit introduced native support for the W3C CSS Scrollbars Level 1 specification, headlined by the standard scrollbar-color and scrollbar-width properties. These standard properties allow web authors to style scrollbar thumbs and tracks declaratively without breaking native macOS gesture physics, dynamic auto-hiding overlays, or platform accessibility settings.
In Safari Web Inspector on macOS, web developers can inspect computed scrollbar declarations, verify inheritance cascades across scrollable containers, test colour contrast ratios, and toggle scrollbar dimensions in real time.
Enabling Safari Web Inspector on macOS
To inspect and debug scrollbar styles, ensure Safari’s developer tools are enabled. If the Develop menu is not visible in the macOS menu bar, activate it via Safari settings:
- Open Safari and navigate to Safari > Settings (or press
Cmd + ,). - Select the Advanced tab.
- Check the box labelled “Show features for web developers” (in earlier macOS versions, “Show Develop menu in menu bar”).
With developer features active, right-click any scrollable element on the webpage and select Inspect Element, or press Option + Cmd + I to open Web Inspector.
Syntax and Behaviour of CSS scrollbar-color
The scrollbar-color property accepts two color values: the first value applies to the scrollbar thumb (the draggable bar), and the second value applies to the scrollbar track (the background gutter):
/* Standard W3C scrollbar-color declaration */
.scrollable-panel {
scrollbar-color: #6366f1 #f3f4f6;
}
Key operational rules govern how Safari renders scrollbar-color:
- Thumb and Track Order: The first color is always the thumb; the second color is always the track. Passing a single color results in an invalid declaration.
- Auto Keyword: Setting
scrollbar-color: auto;restores the operating system’s default native appearance. - macOS Overlay Scrollbars: By default on macOS, scrollbars only appear when scrolling or moving the mouse cursor unless the user has configured system settings to “Always show scrollbars”. When
scrollbar-coloris applied, Safari preserves this dynamic auto-hiding behavior, displaying the custom thumb colour only during user interaction.
Syntax and Behaviour of CSS scrollbar-width
The companion property scrollbar-width governs the physical thickness of the scrollbar gutter. It accepts three standardized keyword values:
/* Standard W3C scrollbar-width declaration */
.scrollable-panel {
scrollbar-width: thin;
}
The supported keywords provide clean layout adaptability:
auto:Default platform scrollbar thickness.thin:A slender, modern scrollbar footprint ideal for navigation sidebars, modal dialogue windows, and code blocks.none:Hides the visual scrollbar entirely while completely preserving user scrollability via mouse wheel, trackpad gestures, or touch swipes. This completely replaces fragile legacy hacks like::-webkit-scrollbar { display: none; }.
Inspecting Computed Scrollbar Properties in Safari Web Inspector
To audit active scrollbar declarations in Web Inspector:
- In the Elements panel, select the target scrollable container (e.g. an element with
overflow-y: autooroverflow: scroll). - In the right-hand panel, select the Computed tab.
- Filter for
scrollbarto inspect the active values:scrollbar-color: Displays the resolved thumb and track colour values.scrollbar-width: Displaysauto,thin, ornone.
If the properties appear struck through in the Styles panel, verify that conflicting legacy ::-webkit-scrollbar pseudo-elements are not declared in the same stylesheet. In WebKit’s implementation, presence of legacy ::-webkit-scrollbar rules may override or conflict with standard scrollbar properties.
Building Dark Mode Adaptable Scrollbars
Combine scrollbar-color with CSS custom properties and color-scheme to build scrollbars that dynamically synchronise with light and dark themes:
/* Root scrollbar definitions with dark mode awareness */
:root {
--scrollbar-thumb: #9ca3af;
--scrollbar-track: #f3f4f6;
color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
:root {
--scrollbar-thumb: #4b5563;
--scrollbar-track: #1f2937;
}
}
.terminal-view,
.content-feed {
overflow-y: auto;
scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
scrollbar-width: thin;
}
Live-Editing and Simulating Scrollbar States
In the Web Inspector Styles panel, you can test custom scrollbar palettes interactively:
- Select the target container in the DOM tree.
- Click inside
element.style {}and addscrollbar-width: thin;. Notice how the scrollbar instantly scales to a slender profile. - Add
scrollbar-color: #3b82f6 #e5e7eb;. Click the colour swatch picker next to the HEX values to adjust opacity and ensure sufficient contrast against background text. - Switch the value to
scrollbar-width: none;to verify that the element remains fully scrollable without visual clutter.
Adopting standard CSS scrollbar-color and scrollbar-width simplifies cross-browser styling, eliminates obsolete WebKit hacks, and delivers native, fluid scroll experiences across Apple platforms.