Scrollbars are a usability and accessibility concern, and the usual rule of thumb is simple: any area that scrolls should show a scrollbar. Platforms themselves do not always follow that rule. macOS hides scrollbars by default and reveals them contextually or on interaction, and iOS behaves the same way, which has led to its own confusing moments.

Where the convention is broken anyway, there is a technique created by Thomas Gladdines that hides the scrollbar by default and reveals it only while the element is hovered. In quick testing it held up across Chrome, Firefox and Safari, regardless of macOS settings.

How the mask sits over the scrollbar

The mechanism relies on mask covering the scrollbar itself. A mask roughly as wide as the scrollbar — 17px is the guess used here — and very tall can cover it completely; both dimensions would ideally be computed by a script. Because the mask is a positioned element, its position can be transitioned, which fakes a fade in and fade out. Importantly, this is the element's real scrollbar, not a simulated one.

Alternative approaches

  • A virtual scrollbar. Ben Nadel documented how Slack does this: force the scrollbar to render in an area hidden by overflow, then draw a virtual scrollbar that mimics the native one, giving you more direct control.
  • Forcing the scrollbar. A separate option if you are so motivated.
  • Styling the scrollbar. Nothing in the mask technique prevents it, and it may bring benefits such as specifying the scrollbar's exact width.