ScrollArea

A scroll container with thin, token-coloured scrollbars. Scrolling stays native: wheel, touch, keyboard, find-in-page and scroll anchoring all work, and nothing is re-implemented in JavaScript.

BetaSource
  • v0.24.0 — New components
  • v0.23.0 — Bug fixes
  • v0.22.0 — Docs and tokens
  • v0.21.0 — New components
  • v0.20.0 — Bug fixes
  • v0.19.0 — Docs and tokens
  • v0.18.0 — New components
  • v0.17.0 — Bug fixes
  • v0.16.0 — Docs and tokens
  • v0.15.0 — New components
  • v0.14.0 — Bug fixes
  • v0.13.0 — Docs and tokens
  • v0.12.0 — New components
  • v0.11.0 — Bug fixes
  • v0.10.0 — Docs and tokens
  • v0.9.0 — New components
  • v0.8.0 — Bug fixes
  • v0.7.0 — Docs and tokens
  • v0.6.0 — New components
  • v0.5.0 — Bug fixes
  • v0.4.0 — Docs and tokens
  • v0.3.0 — New components
  • v0.2.0 — Bug fixes
  • v0.1.0 — Docs and tokens

Import

import { ScrollArea } from "@meridui/react";

Examples

Horizontal, scrollbar on hover

orientation picks the axis ("vertical", "horizontal" or "both"). autoHide shows the scrollbar only while the area is hovered or has focus, on devices with a fine pointer.

reactcsstokensaccessibilityrtldark modedensityserver componentsformsoverlaystables

API reference

Accepts every <div> attribute.

PropTypeDefaultDescription
orientation"vertical" | "horizontal" | "both""vertical"Which axes scroll.
maxHeightCSSProperties["maxHeight"]–Maximum height before it scrolls, e.g. 240 or "50vh".
autoHidebooleanfalseShow the scrollbar only while hovered or focused (fine pointers).
labelstring"Scrollable content"Accessible name used when the area becomes a focusable region.
refRef<HTMLDivElement>–Forwarded ref to the scrolling element.

Styling

ClassElement
.mrd-scroll-areaThe scrolling element
Attribute / variableValues
data-orientationvertical, horizontal, both
data-autohidepresent with autoHide
--mrd-scroll-thumbthumb colour; defaults to --mrd-line-strong

The scrollbar uses scrollbar-width: thin and scrollbar-color (plus ::-webkit-scrollbar for older Safari). In forced-colours mode the system scrollbar is used.

Accessibility

When the content overflows and contains nothing focusable, the area becomes role="region" with tabIndex={0} and the label as its name, so keyboard users can reach it and scroll with the arrow keys (WCAG 2.1.1). When it holds links or buttons it stays out of the Tab order: focusing those scrolls the area.

KeyAction
ArrowUpArrowDownScroll vertically (browser default, once the area has focus).
ArrowLeftArrowRightScroll horizontally.
PageUpPageDownScroll by a page.
HomeEndScroll to the start or end.
  • Table: has its own horizontal scroll frame (scrollLabel).
  • Command: its list scrolls natively in the same way.