Thanks to visit codestin.com
Credit goes to www.cssportal.com

CSS Portal

CSS scrollbar-gutter Property

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The scrollbar-gutter property controls whether the browser should reserve space for the scrollbar area on an element even when a scrollbar is not currently present. Its primary purpose is to eliminate or reduce layout shifts that occur when content toggles between scrollable and non-scrollable states (for example, when content is dynamically added or removed, or when window size changes). By reserving the gutter in advance, the content width and alignment remain stable, which avoids sudden reflows and prevents nearby elements from jumping horizontally when a scrollbar appears or disappears.

Beyond avoiding visual shifts, reserving scrollbar space affects how hit testing and pointer targets behave near the element edges. When the gutter is reserved inside an element’s box it reduces the space available for the element’s content and interactive children, similar to how an inner inset would. When the gutter is reserved outside the element’s box it preserves the content area while allocating space adjacent to the element. This has implications for layout and positioning: fixed or absolutely positioned descendants, sticky headers, and columns with synchronized widths will all behave more predictably when the gutter is taken into account. It also interacts with overlay-style scrollbars (which float above content) differently from classic inset scrollbars that consume layout space, so authors should consider the expected scrollbar presentation for their target platforms.

The behavior of scrollbar-gutter is applied in the context of an element’s scrolling rules and box model — in practice it’s relevant wherever scrollbars may appear, so it’s important to understand how it works with the element’s overflow handling and spacing. For example, the appearance of scrollbars is controlled by overflow, and reserving a gutter will change the effective area available for content in a way similar to adding internal spacing via padding. Because it changes layout metrics, using gutter reservation can simplify responsive designs and animations by preventing unexpected reflows, improving perceived performance and reducing visual jitter when content or viewport size changes.

Definition

Initial value
auto
Applies to
scrolling boxes
Inherited
no
Computed value
as specified
Animatable
yes
JavaScript syntax
object.style.scrollbarGutter

Syntax

scrollbar-gutter: auto | stable && both-edges?

Values

  • 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.

Example

<div class='wrapper'>
<div class='panel'>
<h3>Without scrollbar-gutter</h3>
<div class='box no-gutter'>
<p>Item 1</p>
<p>Item 2</p>
<p>Item 3</p>
<p>Item 4</p>
<p>Item 5</p>
<p>Item 6</p>
<p>Item 7</p>
<p>Item 8</p>
<p>Item 9</p>
<p>Item 10</p>
</div>
</div>

<div class='panel'>
<h3>With scrollbar-gutter: stable both-edges</h3>
<div class='box with-gutter'>
<p>Item 1</p>
<p>Item 2</p>
<p>Item 3</p>
<p>Item 4</p>
<p>Item 5</p>
<p>Item 6</p>
<p>Item 7</p>
<p>Item 8</p>
<p>Item 9</p>
<p>Item 10</p>
</div>
</div>
</div>
* {
  box-sizing: border-box;
}

body {
  font-family: system-ui, Arial, sans-serif;
  margin: 20px;
  background: #f7f7f8;
  color: #222;
}

.wrapper {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.panel {
  width: 320px;
}

h3 {
  margin: 0 0 8px 0;
  font-size: 15px;
}

.box {
  height: 140px;
  overflow: auto;
  padding: 12px;
  border: 1px solid #d0d6db;
  background: #fff;
  border-radius: 6px;
  line-height: 1.4;
}

/* Default behavior: scrollbar appears and may cause layout shift */
.no-gutter {
  scrollbar-gutter: auto;
}

/* Reserve space for the scrollbar to avoid layout shifts when it appears */
.with-gutter {
  scrollbar-gutter: stable both-edges;
}

.box p {
  margin: 6px 0;
}

Browser Support

The following information will show you the current browser support for the CSS scrollbar-gutter property. Hover over a browser icon to see the version that first introduced support for this CSS property.

This property is supported in some modern browsers, but not all.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 1st January 2026

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!