Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Next.js and React

Custom ::-webkit-scrollbar styles vanished after a Chrome update

Your error

::-webkit-scrollbar design is not working in Chrome 1211 more line it can show

Fix it fast

Most common cause, 1 of 2

The scroller itself has scrollbar-width or scrollbar-color

Decide which system draws this scrollbar.

Fix
.scroller {
  overflow: auto;
  scrollbar-width: auto;   /* or delete the line */
  scrollbar-color: auto;
}
.scroller::-webkit-scrollbar { width: 10px; }
.scroller::-webkit-scrollbar-thumb { background: #888; border-radius: 8px; }
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

From Chrome 121, ::-webkit-scrollbar and ::-webkit-scrollbar-thumb styles are ignored on any element whose computed scrollbar-color or scrollbar-width is not auto. scrollbar-color is inherited, so one value on html or body turns custom thumbs off everywhere. Remove the standard properties, set scrollbar-color: auto on the scroller, or rebuild the design with the standard properties.

  • Applies to Chrome 121 to 158 stable, CSS Scrollbars Styling Module Level 1
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Open DevTools on the page, then read the computed scrollbar values of the element that scrolls and of the root element. A non-auto value on the scroller's own rules points to cause 1; auto in the scroller's rules but a colour pair inherited from the root points to cause 2.

Run this first
const el = document.querySelector('.scroller');   // your scrolling element
const cs = getComputedStyle(el);
console.log(cs.getPropertyValue('scrollbar-color'), cs.getPropertyValue('scrollbar-width'));
console.log(getComputedStyle(document.documentElement).getPropertyValue('scrollbar-color'));

Then find the line you see in this list and open its fix:

  1. 1The scroller itself has scrollbar-width or scrollbar-colorThe Styles pane shows scrollbar-width: thin (or a scrollbar-color pair) in a rule that matches the scroller, including a universal * rule
  2. 2scrollbar-color is inherited from html, body or a parentNo rule on the scroller mentions a scrollbar property, yet its computed scrollbar-color is a colour pair and the Computed tab traces it to an ancestor

What does the error look like?

  • ::-webkit-scrollbar design is not working in Chrome 121
  • ::-webkit-scrollbar-thumb border-radius and width ignored, the default scrollbar shows instead

Cause 1 of 2

The scroller itself has scrollbar-width or scrollbar-color

You seeThe Styles pane shows scrollbar-width: thin (or a scrollbar-color pair) in a rule that matches the scroller, including a universal * rule

Check

Custom ::-webkit-scrollbar styling stops working in Chrome 121 and later because the element now carries a standard scrollbar property that is not auto. Chrome added scrollbar-color and scrollbar-width in version 121, and a non-auto computed value of either one makes the browser skip every ::-webkit-scrollbar-* rule for that box. A reset or a library that writes scrollbar-width on every element counts too.

Check
grep -rnE "scrollbar-(color|width)" src --include=*.css --include=*.scss

Fix

Decide which system draws this scrollbar. To keep the custom thumb shape, delete the standard declarations from the scroller or set both back to auto. Going the standard route instead means giving up pixel widths and rounded thumbs, because scrollbar-width only accepts auto, thin or none and scrollbar-color sets two colours.

Fix
.scroller {
  overflow: auto;
  scrollbar-width: auto;   /* or delete the line */
  scrollbar-color: auto;
}
.scroller::-webkit-scrollbar { width: 10px; }
.scroller::-webkit-scrollbar-thumb { background: #888; border-radius: 8px; }

Verify

Both computed values print auto for the scroller and the rounded custom thumb is drawn again.

Verify
getComputedStyle(document.querySelector('.scroller')).getPropertyValue('scrollbar-width')

Confirmed by developer.mozilla.org

Did this fix it?

Cause 2 of 2

scrollbar-color is inherited from html, body or a parent

You seeNo rule on the scroller mentions a scrollbar property, yet its computed scrollbar-color is a colour pair and the Computed tab traces it to an ancestor

Check

The webkit pseudo-elements are switched off here by inheritance. scrollbar-color passes down the tree, so a theme that colours the page scrollbar on :root or body also silences every nested ::-webkit-scrollbar rule below it, even in components that never set the property.

Check
getComputedStyle(document.body).getPropertyValue('scrollbar-color')

Fix

Reset the inherited value on the element that should keep its custom scrollbar. MDN documents that scrollbar-color: auto on the element brings its webkit styling back. Moving the page-level rule from :root to the one element that needs it works as well.

Fix
:root { scrollbar-color: #555 #eee; }   /* page scrollbar */

.chat-panel { scrollbar-color: auto; }  /* opt this box back into webkit rules */
.chat-panel::-webkit-scrollbar-thumb { background: #7c3aed; border-radius: 6px; }

Verify

The scroller's computed scrollbar-color now reads auto while the page keeps its coloured scrollbar.

Verify
getComputedStyle(document.querySelector('.chat-panel')).getPropertyValue('scrollbar-color')

Confirmed by developer.mozilla.org

Did this fix it?

How do I stop it coming back?

  • Before adding scrollbar-color to :root or body, search the codebase for ::-webkit-scrollbar rules, since the inherited value overrides all of them.
  • Write scrollbar styles once with the @supports pattern from Chrome's guide, so browsers with the standard properties use them and older ones fall back to the webkit rules.
  • Keep every scrollbar rule in one stylesheet partial instead of splitting it between a reset and the components.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.