# Stable Layouts with scrollbar-gutter

> Prevent layout shifts when scrollbars appear

Published: 2024-11-24  
Tags: css  
Source: https://www.rege-dev.xyz/writing/scrollbar-gutter

The `scrollbar-gutter` property reserves space for the scrollbar, preventing layout shifts when content grows.

- `auto`: The default behavior. Layout shifts may occur when the scrollbar appears or disappears.
- `stable`: Reserves space for the scrollbar even when not present, preventing layout shifts.
- `stable both-edges`: Reserves space on both sides of the container for perfect symmetry.

[Read more on MDN →](https://developer.mozilla.org/en-US/docs/Web/CSS/scrollbar-gutter)

```css
/* Apply to the scroll container */
.scroll-container {
  scrollbar-gutter: stable;
}
```

_Interactive demo: https://www.rege-dev.xyz/writing/scrollbar-gutter_
