You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to understand the technique Radix UI uses on their website to make the scrollbar behave as if it doesn't exist. Specifically:
There is 0 layout shift, whether the page has a scrollbar or not.
They lock scroll without causing layout changes.
The page looks the same whether it is scrollable or not.
I'm especially interested in how Radix Dialog removes the page scrollbar without leaving any empty space on the body behind the dialog.
Normally, when overflow: hidden is applied to , the scrollbar disappears and the viewport becomes wider, causing:
Content to shift horizontally
Or a blank/white space to appear on the right side
But Radix’s Dialog somehow prevents this completely. I want to understand the exact mechanism they use to hide the scrollbar while keeping the page width visually identical, preventing any space from appearing where the scrollbar used to be.
Note: For anyone recommending it, I don’t think scrollbar-gutter: stable is the fix for this.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to understand the technique Radix UI uses on their website to make the scrollbar behave as if it doesn't exist. Specifically:
There is 0 layout shift, whether the page has a scrollbar or not.
They lock scroll without causing layout changes.
The page looks the same whether it is scrollable or not.
I'm especially interested in how Radix Dialog removes the page scrollbar without leaving any empty space on the body behind the dialog.
Normally, when overflow: hidden is applied to , the scrollbar disappears and the viewport becomes wider, causing:
Content to shift horizontally
Or a blank/white space to appear on the right side
But Radix’s Dialog somehow prevents this completely. I want to understand the exact mechanism they use to hide the scrollbar while keeping the page width visually identical, preventing any space from appearing where the scrollbar used to be.
Note: For anyone recommending it, I don’t think scrollbar-gutter: stable is the fix for this.
Beta Was this translation helpful? Give feedback.
All reactions