โœฆ StealThis .dev

Scroll Area

Custom-styled scrollable container with thin styled scrollbar, auto-hide on idle, and horizontal + vertical variants.

Open in Lab
css vanilla-js
Targets: JS HTML

Code

Scroll Area

Custom-styled scrollable containers with thin, themed scrollbars that auto-hide when idle. Three layout variants: vertical, horizontal, and both axes.

Variants

  • Vertical โ€” fixed-height list with 20 items, thin right scrollbar
  • Horizontal โ€” row of wide cards with bottom scrollbar
  • Both axes โ€” free-scroll content area with scrollbars on both sides

How it works

  1. ::-webkit-scrollbar resets the default browser scrollbar to 6px width/height
  2. The thumb uses rgba(255,255,255,0.15) at rest and rgba(255,255,255,0.3) on hover
  3. A JS scroll listener adds .scrolling to the container; a 1 s debounced timeout removes it
  4. CSS transitions on scrollbar-color and thumb opacity create a smooth fade-in/out
  5. Firefox uses scrollbar-width: thin and scrollbar-color for cross-browser support

CSS-only fallback

The auto-hide behaviour requires JS, but the styled scrollbar is pure CSS. Removing the script degrades gracefully โ€” the scrollbar stays visible but still looks correct.