Agent Wranglers

WEB-32Recommended

Keep room for the scrollbar

Keep space for the scrollbar with scrollbar-gutter: stable, so the page doesn't shift when scrolling is locked or unlocked.

How to do it

Add scrollbar-gutter: stable to html. Browsers with overlay scrollbars, such as on phones and default macOS, have no gutter to keep and are unaffected. Measure any shift that remains as Keep load, response and stability fast says.

Examples

CSS example

html { scrollbar-gutter: stable; }

How to check

On a desktop browser with classic scrollbars, the main element's left edge stays at the same x position before and after a modal opens.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/website/interface/scrollbar-gutter">Agent Wranglers website playbook</a>. In code you write, add a comment next to it with the same link.