Skip to content

Scroll Area

Tags

v1.2.0-beta.50

v1.2.0-beta.49

v1.2.0-beta.48

v1.2.0-beta.47

v1.2.0-beta.46

v1.2.0-beta.45

v1.2.0-beta.44

v1.2.0-beta.43
<div class="scroll-area" tabindex="0" style="height: 12rem"></div>

The element scrolls itself — this only restyles the bar. Give it a height (or a max-height), and tabindex="0" so it can be scrolled from the keyboard.

AttributeMeaning
data-orientation="horizontal"Scrolls sideways only
data-orientation="vertical"Scrolls down only
data-bars="hidden"No visible bar, same scrolling
Photo by Ada
Photo by Grace
Photo by Alan

The bar is gone, the scrolling is not.

Wheel, trackpad, touch and the keyboard all still work.

Only reach for this where an edge already says there is more.

Otherwise people cannot tell the content continues.

Radix draws its own scrollbars, so they look identical in every browser. That costs the native scroll: momentum on a trackpad, overscroll, the platform’s own keyboard handling, and correct behaviour when the page is zoomed. scrollbar-width and scrollbar-color are now supported everywhere, and WebKit takes ::-webkit-scrollbar — enough to get the same look and keep the scroller the browser gave you.

Set dir="rtl" on the page or on any subtree — the bar moves to the left edge, which the browser does on its own. See the button page for a live example.

  • A scrollable box must be focusable. tabindex="0" is what lets a keyboard user reach it and scroll it; without it, content inside is unreachable unless it holds its own controls.
  • Give it a name when it is focusablearia-label or aria-labelledby — so a screen reader says what the region is rather than announcing a bare group.
  • Do not turn off overflow to hide the bar. data-bars="hidden" keeps the element scrollable; overflow: hidden would trap the content.
  • The bar respects the theme, drawn from --border, so it stays visible in dark mode instead of inheriting whatever the OS decided.