Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Layout & primitives

ScrollArea

Free2.1 KB gzipped

A 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

tsx
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.

  • Player 1
  • Player 2
  • Player 3
  • Player 4
  • Player 5
  • Player 6
  • Player 7
  • Player 8
  • Player 9
  • Player 10
  • Player 11
  • Player 12
  • Player 13
  • Player 14
  • Player 15
  • Player 16
  • Player 17
  • Player 18
  • Player 19
  • Player 20
  • Player 21
  • Player 22
  • Player 23
  • Player 24
tsx
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.

Point guardShooting guardSmall forwardPower forwardCenterSixth manBench
tsx
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

  • Player 1
  • Player 2
  • Player 3
  • Player 4
  • Player 5
  • Player 6
  • Player 7
  • Player 8
  • Player 9
  • Player 10
  • Player 11
  • Player 12
  • Player 13
  • Player 14
  • Player 15
  • Player 16
  • Player 17
  • Player 18
  • Player 19
  • Player 20
  • Player 21
  • Player 22
  • Player 23
  • Player 24
tsx
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.

tsx
<ScrollArea maxHeight="20rem" aria-label="Roster">
  <List>…</List>
</ScrollArea>

API reference

ScrollArea

New in 1.5.0
ScrollArea props
PropTypeDefault
children

The scrolling content.

ReactNode—
type

When the scrollbars show.

"auto""hover""scroll""always""auto"
scrollbars

Which directions scroll.

"vertical""horizontal""both""vertical"
size

Scrollbar thickness.

"sm""md""md"
maxHeight

Maximum height of the area (any CSS length, or px as a number). Without it, give the area a height.

CSSProperties["maxHeight"]—
shadows

Fade the edges where more content is hidden, so it's clear the area scrolls even before the scrollbar is noticed.

booleantrue
hideDelay

How long the scrollbars stay after scrolling stops, for hover and scroll, in ms.

number800
viewportRef

Ref to the scrolling viewport element (to read or set scrollTop, or call scrollTo). ref goes to the outer root.

Ref<HTMLDivElement>—
viewportClassName

Class name for the viewport.

string—
onViewportScroll

Called 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)

Running accessibility audit

Checking the examples above…

Lighthouse audit

Light mode

Score 100

35 passed · 0 failed · 30 not applicable · 10 to check by hand

Dark mode

Score 100

35 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

Keyboard
KeyAction
TabWhile the content overflows, the viewport is a tab stop.
Arrow keysScroll the focused viewport.
Page UpPage DownScroll a page at a time.
HomeEndScroll 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

Roles and states
ElementRoleStates and properties
Viewportregion (when named)aria-label or aria-labelledby; tabindex="0" while it overflows
Custom scrollbarsnonearia-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.

Manual accessibility checks
CheckWhat to testWCAG 2.2
KeyboardEvery 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)
FocusFocus 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 readersNames, 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)
ColorMeaning 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 reflowAt 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 targetsClick 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)
MotionAnimations respect the reduced-motion setting.2.3.3 (AAA)