Zach’s ugly mug (his face) Zach Leat­herman

A tiny bit-o-CSS for Stable Scrollbar Gutters

September 18, 2025 On Mastodon

I have my operating system configured to use visible scrollbars, a feature prominently elevated in macOS’ System Settings high enough that it would seem to imply some level of common usage (even though it’s not a default).

I don’t necessarily prefer the behavior this feature enables but I use it as an implied measure of quality when browsing the web .

I typically see the following problems:

  1. Pages that have horizontal overflow (and a scrollbar to match) are more obvious.
  2. Pages may move ~20px horizontally when sites toggle document-level overflow: hidden when toggling modals/dialogs.
  3. On particulary slow pages you may even see pages shift when progressively rendering content slower than it can fill one “page fold.”

The easiest thing folks can do to workaround this issue is add html { overflow-y: scroll; } to your CSS resets, which can be a great way to very easily reduce those content layout shift issues! But this little snippet adds a scrollbar to every page.

To show scrollbars only when they’re needed (while keeping space for the scrollbar if it’s added later) use the scrollbar-gutter CSS property. scrollbar-gutter is Baseline 2024 Newly Available, so make sure you enhance it with a @supports guard.

html {
	overflow-y: scroll;
}
@supports (scrollbar-gutter: stable) {
	html {
		overflow-y: auto;
		scrollbar-gutter: stable;
	}
}

This would look great in your reset stylesheet.

Related:


Older >
A note from my late Grandmother about Eleventy

Zach Leatherman IndieWeb Avatar for https://zachleat.com/is a builder for the web at Font Awesome and the creator/maintainer of IndieWeb Avatar for https://www.11ty.devEleventy (11ty), an award-winning open source site generator. At one point he became entirely too fixated on web fonts. He has given 85 talks in nine different countries at events like Beyond Tellerrand, Smashing Conference, Jamstack Conf, CSSConf, and The White House. Formerly part of CloudCannon, Netlify, Filament Group, NEJS CONF, and NebraskaJS. Learn more about Zach »

25 Reposts

Björn BerkholzJoe GlombekZach Leatherman :11ty:Lea RosemaIndieWeb Avatar for https://jeffbridgforth.comŠime VidasGerardo LisboaSteve FrenzelAmelia Bellamy-RoydsAssaf ????David RoessliCamron FlandersJean Pierre KolbRyan MulliganSarah FriskNick TaylorStefan MateiJake LazaroffKevin PowellJesse SutherlandThomas Steiner :chrome:theAdhocracydanklingjrAleksandr YakunichevAxel Rauschmayer

65 Likes

RazunterJTtbesedaLea RosemaEric PortisØystein HåbergMahmoud From Gaza ????????????SaulDCoder ????????❤????????Steve FrenzelSindre BøyumChris Silverman ????travisFatih AltinokRandom UsernameRyan GroveMachineSpeakmajjoNick FShawKevin KippDavid RoessliMykyta BatrakAndy BondJelmerJean Pierre KolbAlexi ChepuraaveryJon RobertsJamie Boydjrlarsenjerad⛺ Humble Life SkillsKevin PowellSamAmy WoodworthNilesh PrajapatiJesse SutherlandSarah FriskBryanJake LazaroffCSS-Tricks*Joost SchuurMason ConkrightNate FlickSergioRicardo AmaralDisplay NameNéha @ Nebula's CodeNick TaylorStefan MateiTony MessiasYann ????????????????AnjaBSteve Bogart ????Matt Gaunt-SeotheAdhocracyBenoît LaunayMax FentondanklingjrScottmyfAleksandr Yakunichev

1 Bookmark

IndieWeb Avatar for https://adactio.com
3 Comments
  1. `scrollbar-gutter` is great, but I don't know if I'd go so far as to argue that everyone should be putting it in their resets. As far as I'm aware, there's currently no way to put *anything* in the space it reserves, which unfortunately makes it awkward to use wit… Truncated

  2. Bramus

    As long as you don’t go for `scrollbar-gutter: stable both-edges`, you should be fine. Reason: Chrome has a bug in which the gutter is doubled up on “retina” devices: issues.chromium.org/issues/40064... (The bug is assigned, and I heard engineering will look at it next quarter)

  3. Bramus

    There’s still some discussion on how viewports should behave in this case. What the WG did resolve on – but this hasn’t been implemented anywhere (????) – is that top layer content (such as a modal dialog and its backdrop, or a fullscreen video) can draw on top of the reserved s… Truncated

Shamelessly plug your related post

These are webmentions via the IndieWeb and webmention.io.

Sharing on social media?

This is what will show up when you share this post on Social Media:

How did you do this? I automated my Open Graph images. (Peer behind the curtain at the test page)