CSS Reference ยท Scrolling, Interaction and UI
The scrollbar-gutter property
Reference for the CSS scrollbar-gutter property: reserve room for classic scrollbars so content does not jump when a scrollbar appears, with a live example.
On systems with classic scrollbars, a scrollbar takes space from the content box. When content grows and a scrollbar suddenly appears, the text area gets narrower and the layout jumps. The scrollbar-gutter property avoids this by reserving the space (the gutter) in advance, whether or not a scrollbar is showing.
On systems with overlay scrollbars that float over the content, there is no gutter to reserve, so the property has no visible effect.
.chat { overflow-y: auto; scrollbar-gutter: stable; }
Try it
On a system with classic scrollbars, the right box shows a strip of empty space where a scrollbar would be, and its content keeps the same width if the content later becomes taller.
Syntax
scrollbar-gutter: auto | stable && both-edges?;
- Initial value:
auto - Applies to: scroll containers
- Inherited: no
- Animatable: no
- Computed value: as specified
Values
| Value | Description |
|---|---|
auto |
The gutter exists only while a scrollbar is shown. |
stable |
The gutter is reserved on the side of the scrollbar even when no scrollbar is displayed, as long as overflow is auto, scroll or hidden. |
stable both-edges |
Reserves the gutter on both inline edges, so content stays visually centered. |
Usage notes
- Use
stableon panels, modals and the root element if content changes size often and you want to avoid shifting. - With
both-edges, the symmetrical space keeps centered content centered; without it, the layout leans away from the scrollbar side. - It does nothing when
overflowisvisible, and it is not needed foroverflow: scroll, which always shows a scrollbar on classic-scrollbar systems. - Its effect combines with
scrollbar-width: a thinner scrollbar reserves a thinner gutter, andnonereserves none. - The old workaround, forcing
overflow-y: scrollonhtml, shows a disabled track on short pages;scrollbar-gutteris the cleaner fix.
Browser support
Supported in current Chromium-based and Firefox browsers, and in recent Safari versions; check a compatibility table for older releases, which ignore it and behave as auto.
Related
scrollbar-widthโ scrollbar thicknessscrollbar-colorโ scrollbar colorsoverflowโ creates scroll containers- Lesson: Scroll Snap