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.
- 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 { ScrollArea } from "@meridui/react";
export function Example() {
return (
<ScrollArea maxHeight={200} label="Release history">
<ul>
{releases.map((release) => (
<li key={release}>{release}</li>
))}
</ul>
</ScrollArea>
);
}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.
<ScrollArea orientation="horizontal" autoHide label="Tags">
<div style={{ display: "flex", gap: 8, width: "max-content" }}>
{tags.map((tag) => (
<Badge key={tag}>{tag}</Badge>
))}
</div>
</ScrollArea>API reference
Accepts every <div> attribute.
| Prop | Type | Default | Description |
|---|---|---|---|
orientation | "vertical" | "horizontal" | "both" | "vertical" | Which axes scroll. |
maxHeight | CSSProperties["maxHeight"] | – | Maximum height before it scrolls, e.g. 240 or "50vh". |
autoHide | boolean | false | Show the scrollbar only while hovered or focused (fine pointers). |
label | string | "Scrollable content" | Accessible name used when the area becomes a focusable region. |
ref | Ref<HTMLDivElement> | – | Forwarded ref to the scrolling element. |
Styling
| Class | Element |
|---|---|
.mrd-scroll-area | The scrolling element |
| Attribute / variable | Values |
|---|---|
data-orientation | vertical, horizontal, both |
data-autohide | present with autoHide |
--mrd-scroll-thumb | thumb 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.
| Key | Action |
|---|---|
| ArrowUpArrowDown | Scroll vertically (browser default, once the area has focus). |
| ArrowLeftArrowRight | Scroll horizontally. |
| PageUpPageDown | Scroll by a page. |
| HomeEnd | Scroll to the start or end. |