Layout & primitives
ScrollArea
Free2.1 KB gzippedA scrolling region with slim, on-brand scrollbars that work the same in every browser. Scrolling itself stays native (wheel, touch, trackpad momentum, keyboard, find-in-page, scroll anchoring); only the look of the bars is custom. The thumbs can be dragged, and pressing the track pages toward the press.
Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · Keys: Tab, Arrow keys, Page Up and 3 more · Full report
Import
import { ScrollArea } from "@vjdesigns/vjdesigns-ui";
Importing only ScrollArea adds about 2.1 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.
Examples
Basic
A region that scrolls past maxHeight, with slim, on-brand scrollbars. Scrolling stays native. While it overflows it's a tab stop, so the arrow keys and Page Up / Page Down scroll it, and aria-label names it as a region.
import { List, ScrollArea } from "@vjdesigns/vjdesigns-ui";
const players = Array.from({ length: 24 }, (_, i) => `Player ${i + 1}`);
export function Basic() {
return (
<ScrollArea maxHeight="14rem" aria-label="Roster" style={{ width: "100%", maxWidth: "20rem" }}>
<List>
{players.map((player) => (
<List.Item key={player}>{player}</List.Item>
))}
</List>
</ScrollArea>
);
}
Horizontal
scrollbars="horizontal" for a row that scrolls sideways. Edge shadows show there's more to see.
import { Chip, Flex, ScrollArea } from "@vjdesigns/vjdesigns-ui";
export function Horizontal() {
return (
<ScrollArea scrollbars="horizontal" aria-label="Positions" style={{ width: "100%", maxWidth: "24rem" }}>
<Flex gap={2} style={{ width: "max-content", paddingBlock: "0.25rem" }}>
{["Point guard", "Shooting guard", "Small forward", "Power forward", "Center", "Sixth man", "Bench"].map((role) => (
<Chip key={role} variant="outline">
{role}
</Chip>
))}
</Flex>
</ScrollArea>
);
}
Right to left
The first example again, inside a right-to-left LocaleProvider (Arabic). Layout, spacing and arrow icons mirror, and the components' built-in text is translated. The example's own text stays in English.
Basic
import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";
// Basic is the "Basic" example above.
<LocaleProvider locale="ar" messages={ar}>
<Basic />
</LocaleProvider>
Usage notes
Accessibility: while the content overflows, the viewport is focusable (tabIndex=0) so keyboard users can scroll it with the arrow keys, Page Up / Page Down, and Home / End. Give it a name with aria-label or aria-labelledby, which also makes it a region landmark. The custom bars are hidden from assistive technology (they duplicate native scrolling). Edge shadows show there is more to see. In Windows High Contrast mode the native scrollbars come back.
<ScrollArea maxHeight="20rem" aria-label="Roster">
<List>…</List>
</ScrollArea>
API reference
ScrollArea
New in 1.5.0| Prop | Type | Default |
|---|---|---|
childrenThe scrolling content. | ReactNode | — |
typeWhen the scrollbars show. | "auto""hover""scroll""always" | "auto" |
scrollbarsWhich directions scroll. | "vertical""horizontal""both" | "vertical" |
sizeScrollbar thickness. | "sm""md" | "md" |
maxHeightMaximum height of the area (any CSS length, or px as a number). Without it, give the area a height. | CSSProperties["maxHeight"] | — |
shadowsFade the edges where more content is hidden, so it's clear the area scrolls even before the scrollbar is noticed. | boolean | true |
hideDelayHow long the scrollbars stay after scrolling stops, for | number | 800 |
viewportRefRef to the scrolling viewport element (to read or set | Ref<HTMLDivElement> | — |
viewportClassNameClass name for the viewport. | string | — |
onViewportScrollCalled on every scroll of the viewport. | (event: Event & { currentTarget: HTMLDivElement; }) => void | — |
Also accepts native <div> attributes, plus className, style and ref.
See what changed in each version in the Changelog.
Accessibility report
ScrollArea targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.
axe-core audit (live)
Checking the examples above…
Lighthouse audit
Light mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Dark mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.
Built-in behavior
Keyboard
| Key | Action |
|---|---|
| Tab | While the content overflows, the viewport is a tab stop. |
| Arrow keys | Scroll the focused viewport. |
| Page UpPage Down | Scroll a page at a time. |
| HomeEnd | Scroll to the start or end. |
Scrolling is the browser's own, so wheel, touch, trackpad and find-in-page all work. Dragging the custom thumbs is optional: keyboard, wheel and pressing the track do the same.
Roles and states
| Element | Role | States and properties |
|---|---|---|
| Viewport | region (when named) | aria-label or aria-labelledby; tabindex="0" while it overflows |
| Custom scrollbars | none | aria-hidden="true": they duplicate native scrolling |
Manual checks
Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.
| Check | What to test | WCAG 2.2 |
|---|---|---|
| Keyboard | Every action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck. | 2.1.1 (A), 2.1.2 (A) |
| Focus | Focus moves in a logical order, is always visible, and isn't hidden behind sticky headers. | 2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA) |
| Screen readers | Names, roles and states are announced correctly, and status changes are announced without moving focus. | 1.3.1 (A), 4.1.2 (A), 4.1.3 (AA) |
| Color | Meaning never depends on color alone; your own colors meet contrast in both modes. | 1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA) |
| Zoom and reflow | At 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed. | 1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA) |
| Pointer targets | Click and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap. | 2.5.8 (AA), 2.5.5 (AAA) |
| Motion | Animations respect the reduced-motion setting. | 2.3.3 (AAA) |