Since December 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
The scrollbar-gutter CSS property allows authors to reserve space for the scrollbar, preventing unwanted layout changes as the content grows while also avoiding unnecessary visuals when scrolling isn't needed.
An element's scrollbar gutter is the space between the inner border edge and the outer padding edge, where the browser may display a scrollbar. If no scrollbar is present, the gutter will be painted as an extension of the padding.
The browser determines whether classic scrollbars or overlay scrollbars are used:
/* Initial value */ scrollbar-gutter: auto; /* "stable" keyword, with optional modifier */ scrollbar-gutter: stable; scrollbar-gutter: stable both-edges; /* Global values */ scrollbar-gutter: inherit; scrollbar-gutter: initial; scrollbar-gutter: revert; scrollbar-gutter: revert-layer; scrollbar-gutter: unset;
autoThe initial value. Classic scrollbars create a gutter when overflow is scroll, or when overflow is auto and the box is overflowing. Overlay scrollbars do not consume space.
stableWhen using classic scrollbars, the gutter will be present if overflow is auto, scroll, or hidden even if the box is not overflowing. When using overlay scrollbars, the gutter will not be present.
both-edgesIf a gutter would be present on one of the inline start/end edges of the box, another will be present on the opposite edge as well.
| Initial value | auto |
|---|---|
| Applies to | scrolling boxes |
| Inherited | no |
| Computed value | as specified |
| Animation type | discrete |
scrollbar-gutter =
auto |
stable && both-edges?
The examples below show how the different values for the scrollbar-gutter property would affect a scrollable div element (.container) with one or more paragraphs contained within.
Note: In the images for the examples, the user's system settings are set to classic scrollbars (always shown).
Prevent unneeded layout changes as the content growing or shrinking causes the scrollbar to appear/disappear, a space is reserved for it.
.container {
scrollbar-gutter: stable;
}
Add symmetric spacing to both sides of the box so the content is centered:
.container {
scrollbar-gutter: stable both-edges;
}
Align the contents of a non-scrolling element and a scrolling one adjacent to it: This example shows two divs side by side. The one on the left has no scroll, but the one on the right does. Both have scrollbar-gutter applied, which also reserves space for the div on the left which doesn't have scrollable content. This is a good technique to use to keep the width of content consistent.
.container1 {
overflow: hidden;
scrollbar-gutter: stable;
}
.container2 {
scrollbar-gutter: stable;
}
For reference, this image shows the same div as above, but with the user's system settings set to overlay scrollbars. Note here the scrollbar will only show when the user is scrolling and on top of the content, so no space is reserved for it and the scrollbar-gutter property has no effect.
| Specification |
|---|
| CSS Overflow Module Level 3> # scrollbar-gutter-property> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
scrollbar-gutter |
94 | 94 | 97 | 80 | 18.2 | 94 | 97 | 66 | 18.2 | 17.0 | 94 | 18.2 |
auto |
94 | 94 | 97 | 80 | 18.2 | 94 | 97 | 66 | 18.2 | 17.0 | 94 | 18.2 |
stable |
94 | 94 | 97 | 80 | 18.2 | 94 | 97 | 66 | 18.2 | 17.0 | 94 | 18.2 |
overflowscrollbar-widthscrollbar-color
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/scrollbar-gutter