← blog
CSSNovember 27, 2026 · 6 min read

I Deleted My Scrollbar Hacks. scrollbar-color Replaced Them.

A dashboard's scrollbar matched Figma in Chrome and looked broken in Firefox. scrollbar-color and scrollbar-width fix that with two lines of standard CSS — no vendor prefixes, no UA sniffing.

Parsa Jiravand · Frontend engineer · building bestpractic
I Deleted My Scrollbar Hacks. `scrollbar-color` Replaced Them.

The Figma handoff said "thin gray scrollbar, rounded thumb, matches the rest of the UI." Twenty minutes and one Stack Overflow answer later, it did — in Chrome. The PR screenshot looked exactly like the design. It shipped.

Three days later: "scrollbars look broken in Firefox." Not styled-wrong broken. Default-Windows-95 broken — the fat gray bar with square ends, like the CSS had never been written at all.

It hadn't been. Not in Firefox, anyway.

The original CSS was the usual ::-webkit-scrollbar trio:

CSS
1
2
3
4
5
6
7
8
9
10
.scroll-panel::-webkit-scrollbar { width: 8px; } .scroll-panel::-webkit-scrollbar-thumb { background: #8b8f98; border-radius: 999px; } .scroll-panel::-webkit-scrollbar-track { background: transparent; }

A quick search turns up the "real" fix: add scrollbar-width and scrollbar-color, the standards-track properties, and Firefox will fall in line.

CSS
1
2
3
4
.scroll-panel { scrollbar-width: thin; scrollbar-color: #8b8f98 transparent; /* thumb, track */ }

Added, shipped, closed the ticket. Then the designer opened Firefox and asked why the thumb was square again, and why hovering it didn't darken like it did in Chrome.

Those aren't bugs. They're the entire API. scrollbar-color takes exactly two colors — thumb, then track — and scrollbar-width takes one of three keywords: auto, thin, none. No border-radius. No :hover. No pixel widths. The standard model was never going to reproduce the webkit one, because it isn't trying to.

::-webkit-scrollbar and its siblings (::-webkit-scrollbar-thumb, ::-webkit-scrollbar-track) aren't in any CSS spec. They're a WebKit invention from the 2010s that Blink inherited when Chrome forked from WebKit — which is exactly why they work in Chrome, Edge, Opera, and Safari (all WebKit- or Blink-rendered) and nowhere else. Firefox runs Gecko, and Gecko's maintainers rejected general support for them as a matter of policy, on the record: letting authors reach in and restyle an OS-level UI affordance with arbitrary CSS was the thing they objected to. The one exception is a narrow, Mozilla-curated webcompat shim for a short list of specific sites with broken nested scroll containers — not something your own site can opt into, and it doesn't change what @supports selector(::-webkit-scrollbar) reports anywhere else.

What Gecko shipped instead, back in Firefox 64 (late 2018), was the CSS Scrollbars Module: scrollbar-color and scrollbar-width. Deliberately coarse — two colors and a width keyword — because the point was letting a page hint at a color scheme without letting it fully take over a native control the OS and accessibility tooling still need to reason about.

For five years that was a genuine split: Firefox had the standard properties, every other engine had the non-standard pseudo-elements, and "support both" meant literally writing both and hoping. Chrome and Edge didn't add either standard property until version 121, in January 2024. Safari shipped the pair in two steps: scrollbar-width landed quietly in Safari 18.2, December 2024 — then scrollbar-color, the harder half of the pair, held out a full year longer, only landing in Safari 26.2, released December 2025.

That's not a typo for "last year." As of right now, this is the first point in the standard's history where every current engine — Gecko, Blink, and WebKit — understands scrollbar-color and scrollbar-width at the same time. web-features tags it Baseline "newly available" as of December 2025, not "widely available" yet (that's dated out to 2028, for the usual two-more-years-of-safety reason Baseline uses) — but for a page that doesn't need to support scrollbars on browsers from before this winter, it's already a one-line, no-prefix, every-engine fix.

Runs right in your browser — poke at it and watch the concept react live.

The obvious next move is to try to get the best of both: keep the ::-webkit-scrollbar trio for pixel control, add scrollbar-color/scrollbar-width for Firefox, and gate the webkit rules behind a feature query so each engine only sees what it understands:

CSS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
.scroll-panel { scrollbar-color: #8b8f98 transparent; /* thumb, track */ scrollbar-width: thin; } @supports selector(::-webkit-scrollbar) { .scroll-panel::-webkit-scrollbar { width: 8px; } .scroll-panel::-webkit-scrollbar-thumb { background: #8b8f98; border-radius: 999px; } }

That doesn't do what it looks like it does, not anymore. @supports selector(::-webkit-scrollbar) really does just ask "do you parse this selector" — and in Chrome, Edge, and Safari the answer is still true, they still recognize the syntax. But recognizing a selector and rendering its declarations turned out to be two different things. Starting with Chrome 121, Chromium made a deliberate call: if an element's scrollbar-width or scrollbar-color is set to anything other than its initial value, that element's ::-webkit-scrollbar* rules are ignored outright, no matter what the cascade says. WebKit matched the same behavior for Safari once scrollbar-color shipped there (WebKit bug 257617, resolved fixed). So the moment .scroll-panel has scrollbar-color on it, the border-radius rule below it is dead code in every current engine — true in Firefox for the obvious reason, true in Chrome, Edge, and Safari for this one.

CSS
1
2
3
4
5
/* This is the entire fix, today. There's nothing to layer on top of it. */ .scroll-panel { scrollbar-color: #8b8f98 transparent; /* thumb, track */ scrollbar-width: thin; }

That's not a bug costing you a workaround — it's four engines agreeing, on purpose, that a page which opts into the standard model doesn't get to keep one foot in the proprietary one. Note what this gives you: not "Firefox now looks identical to Chrome," but "every engine renders something you chose, instead of three doing that and one doing whatever its 1995 default is." That's a lower bar than the webkit pseudo-elements on purpose — a scrollbar is still a native control, and forced-colors mode and accessibility tooling get to keep overriding your two colors when a user needs them to.

If a design genuinely needs a scrollbar thinner than thin, a gradient thumb, or a hover state that visibly changes, the standard properties won't get you there in any engine, and now there's a sharper catch: that pixel-level version only renders at all if you leave scrollbar-color/scrollbar-width off that element completely. Add either one back — even scrollbar-width: auto — and the webkit rules you were relying on go dark again, in Chrome and Safari too. So it's a straight either/or, not a fallback chain: pixel-perfect in Chromium and WebKit with zero styling in Firefox, or one coarse look in all four engines. Don't promise a client cross-browser pixel parity on a custom scrollbar; promise one of those two things, not both at once on the same element.

Instant feedback, a hint on every question, and an explanation for each answer — right or wrong.

The ticket didn't close because Firefox caught up to Chrome. It closed because the CSS finally asked each engine the question it could actually answer. Have you got a scrollbar hack in production you haven't opened in Firefox lately? Go check — I'll bet it's not the first corner that non-standard CSS cut without telling you.


🚀 Want more like this? Every guide, playground, and quiz lives on bestpractic.org — open it and sign up free so the next one finds you.

Thanks for reading! Let's stay connected:

Keep reading

One post a day, in your inbox

Each one with a runnable playground and a quiz. No pitch, no digest, unsubscribe in one click.

0 comments

Sign in to join the discussion, like comments, and save articles for later.