Skip to content

[drawer] Scroll lock applies html scrollbar-gutter: stable #4645

Open

Description

@abdiths

Bug report

Current behavior

  • html.style.scrollbarGutter = "stable" is applied while the drawer is open
  • A visible gutter appears outside the drawer
  • The gutter belongs to the page root, not the drawer

Expected behavior

  • no visible gutter outside the drawer
  • gutter compensation should not be visible for side drawers
  • a prop/config should exist to disable this behavior

Reproducible example

  1. Open https://base-ui.com/react/components/drawer
  2. Open the right-side drawer example
  3. Inspect html
  4. Observe inline style: scrollbar-gutter: stable
  5. Notice the reserved gutter/blank strip outside the drawer

Base UI version

^1.3.0

Which browser are you using?

Chrome

Which OS are you using?

Ubuntu & Windows

Which assistive tech are you using (if applicable)?

Voiceover/JAWS etc.

Additional context

This may be intentional for layout shift prevention, but for side drawers the reserved root gutter becomes visibly detached from the drawer and looks broken

Activity

  1. added
    status: waiting for maintainer
    on Apr 17, 2026
  2. added
    component: drawer
    and removed
    status: waiting for maintainer
    on Apr 18, 2026
  3. atomiks commented on Apr 18, 2026

    @atomiks
    Contributor

    Can you show a screenshot of what it looks like? On macOS, with overlay scrollbars disabled, there is no visible gutter for a right drawer

    On Windows (Chrome), I also don't see an issue:

    Screen.Recording.2026-04-18.at.8.30.33.pm.mov
  4. abdiths commented on Apr 18, 2026

    @abdiths
    Author

    I actually do see it in your video!

    EDIT: i just went on my windows machine again and didn't see this issue. it's definitely just my ubuntu laptop running Chrome. Below is an example of that:

    Image
  5. changed the title [-][Drawer] scroll lock applies html `scrollbar-gutter: stable`[/-] [+][drawer] scroll lock applies html `scrollbar-gutter: stable`[/+] on May 8, 2026
  6. changed the title [-][drawer] scroll lock applies html `scrollbar-gutter: stable`[/-] [+][drawer] Scroll lock applies html `scrollbar-gutter: stable`[/+] on May 19, 2026
  7. rindev0901 commented on Jul 10, 2026

    @rindev0901

    same issues, how to remove this

  8. void0jw commented on Jul 18, 2026

    @void0jw

    Having the option "Always show scroll bars" on your macOS or Windows machine makes it instantly visible, especially in light mode.

    With both the option and light mode enabled, if you go to Base UI DIalog and click on the first example, it can be observed:

    Image

    There's the visible scrollbar gutter on the right, that is not covered by the backdrop, making it look funny.


    The Base UI Drawer and it's first example doesn't suffer from this because of the simple colour palette, the background-color of drawer is the same as the gutter, but if you check the example when the drawer is placed at the bottom:

    Image

    It's more apparent when you check out something that has more styles to it, e.g. shadcn Drawer:

    Image

    Radix and Base UI, solves this without the scrollbar-gutter styling, making it work as expected.
    For an easy observation, you can switch to Radix on the shadcn documentation pages or check out MUI's docs, e.g. shadcn Dialog (radix), there's no visible gutter:

    Image

    What's different and what both Radix and MUI seem to be doing is having no overflow and adding the scrollbar width as padding on body.


    It's interesting. Is there a particular reason why it's not solved in the same way?
    I'm on Windows and Firefox, but it behaves exactly the same on my macOS and Chrome.

    This part in useScrollLock.ts seems a little hasty, the supportsStableScrollbarGutter usage

    updateGutterOnly = supportsStableScrollbarGutter(referenceElement);
    
    if (updateGutterOnly) {
      html.style.scrollbarGutter = scrollbarGutterValue;
      elementToLock.style.overflowY = 'hidden';
      elementToLock.style.overflowX = 'hidden';
      return;
    }

    Using scrollbar-gutter when it's available seems like a great idea, using native API's instead of having to solve the gutter manually, but the "Always visible scrollbars" option blows it up ☹️.

  9. atomiks commented on Jul 18, 2026

    @atomiks
    Contributor

    @void0jw you're right that scrollbar-gutter: stable leaves a "white bar" of space on the right in light mode with a dimming backdrop.

    However, the use of that CSS property is intentional to avoid background layout shifts with position: fixed elements. What Radix does looks aesthetically better but runs the risk of strange layout shifts that may start randomly popping up and need to be manually addressed. In a large app with many devs working on it, this almost always starts happening randomly and no one notices for a while.

    Take a look at this comment: #604 (review), particularly the screen recording under "As another example, here is a UI I had built". Notice that the layout shift randomly appeared over time just because scrollbar-gutter: stable wasn't being used? In Base UI layout shifts like that will never occur because of scrollbar-gutter: stable. You never have to worry that this will start happening. No one realized this layout shift was a a thing on WorkOS' site (which uses Radix) until Vlad went and found it. To handle it in Radix, you need to set right: var(--padding-right) (or whatever the variable is called) to ALL position: fixed elements. Since this needs to be manually done for every element, it simply isn't done/is forgotten about extremely easily.

    Base UI's looks fine in dark mode (with dark backdrops), but yes in light mode with a dark/dimming backdrop, it's noticeable. But as Vlad said in that PR:

    The header doesn't move because I did handle that, but the input got messed up over time. Maybe it was me, maybe another developer forgot that; it's natural because you don't anticipate any relationship between a random element on the page and an unrelated dialog.

    My guiding rule here is that great DX and great UX go hand in hand. Compromises in DX tend to lead to end user issues.

    Maybe we can provide an escape hatch for users that really want maximum aesthetics and are willing to manually handle every single position: fixed element in their app. But if you're using Always scrollbars, I don't think aesthetics is the maximum priority, because overlay scrollbars are aesthetically much better. (I personally never have them on because inset scrollbars do not look good on macOS).


    Another comment I made on this, written differently: #4615 (comment)

  10. void0jw commented on Jul 18, 2026

    @void0jw

    @atomiks that explains it, thank you!

    My thinking was that doing it the "radix way" was basically a solved case, a mature solution that doesn't suffer from any edge cases or issues.
    I didn't suspect there was anything more to it - it’s likely just the result of long-term work with UI libraries that always solved it for me.

    Personally, I code with scrollbars set to "always visible" so I can spot content overflow issues early - which is exactly why I noticed this - though I realize this approach might not be very popular 😄

  11. abdiths commented on Jul 18, 2026

    @abdiths
    Author

    Thanks @atomiks for the detailed explanation! Also, I agree, if you turn on always scrollbars, aesthetics isn't your top priority lol. But for Windows/Linux, I think adding the escape hatch would be perfect for those who want to override the inline scrollbar-gutter behavior. It's just the default scrollbar style on there so it's not really a case of someone deliberately trading aesthetics for something else.

    And for those who want the Radix-style behavior in the meantime: forcing the css property to auto works with !important. @rindev0901 do this:

    html {
      scrollbar-gutter: auto !important;
    }
  12. nxtvoid commented on Sep 1, 2026

    @nxtvoid

    i'm seeing the same issue with Base UI 1.7.0 in Brave on Windows. when a modal Dialog opens, scroll locking adds scrollbar-gutter: stable to <html>, leaving a visible blank strip outside the backdrop on the right side.

    it is much more noticeable in light mode, while dark mode mostly hides it because the gutter blends with the page background. i can also reproduce the same behavior on the Base UI documentation site.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: drawer

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions