Skip to content

[scroll-area] Thumb flashes at wrong size on remount #4103

Closed

Description

@boeschj

Bug report

Current behavior

When ScrollArea is unmounted and remounted (inside a baseui Tabs.Panel in this case), the scrollbar thumb renders at the wrong size before correcting on the next user scroll. This is visible when ScrollArea.Scrollbar hasdisplay: flex or display: grid and the thumb has any padding.

The thumb also flashes with an initial height of 0 on page load with Next.js before correcting

Screen.Recording.2026-02-15.at.7.34.25.PM.mov

Expected behavior

The thumb should render at the correct size immediately on mount

Reproducible example

Stackblitz with repro in next.js: https://stackblitz.com/edit/stackblitz-starters-d9hre5ba?file=app%2Fpage.tsx

Base UI version

1.2.0

Which browser are you using?

Chrome

Which OS are you using?

Mac OS

Which assistive tech are you using (if applicable)?

n/a

Additional context

After grappling with this issue for a while, I was curious if this was a CSS issue on my end or a potential bug in the library. After reducing my implementation down to a bare minimum example, and still getting this issue, I started to suspect that the thumb size was being initialized with an incorrect value and corrected after the first paint.

To debug I went into node_modules and checked out ScrollAreaScrollbar and ScrollAreaViewport and left console logs to see what the --scroll-area-thumb-height css variable was being set to, and how often it was changing.

On mount, it did initialize to 0 before updating, and when switching tabs and then scrolling, the height went through three renders from 0px -> 403px on mount, and then to 464px when I began scrolling, which aligns with what I was visually observing.

I was able to partially work around this issue by passing keepMounted to my Tabs.Panel component, but the initial page load flash persists.

Activity

  1. added
    status: waiting for maintainer
    on Feb 16, 2026
  2. linear commented on Feb 16, 2026

    @linear
  3. added
    component: scroll area
    on Feb 16, 2026
  4. added
    type: bug
    and removed
    status: waiting for maintainer
    on Feb 17, 2026
  5. atomiks commented on Feb 17, 2026

    @atomiks
    Contributor

    Have a fix in #4107

    I was able to partially work around this issue by passing keepMounted to my Tabs.Panel component, but the initial page load flash persists.

    In the PR, the SSR behavior changes to hide the scrollbars entirely (unless you specify keepMounted) until hydration. So the scrollbar just flashes in on hydration after mount. It's not possible to fix this without a pre-hydration <script> since the JS needs to run to determine the measurements of all the elements

    The Scroll Area component is mainly useful to add overlay scrollbars on hover or scroll rather than always-visible, unless it's in a popup that requires interaction first (e.g. the cmdk menu on the docs), due to this JS limitation.

  6. github-actions commented on Mar 4, 2026

    @github-actions

    This fix will be available in the next npm release of Base UI.

    In the meantime, you can try it out on our Canary release channel:

    npm i https://pkg.pr.new/@base-ui/react@4107
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: scroll areatype: bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions