videorc/ui

Scroll Area

A native scroller with a thumb-only scrollbar, like macOS overlay scrollbars. The thumb shows while you scroll, on the theme's --scrollbar-* tokens.

Installation

$ pnpm dlx shadcn@latest add @videorc/scroll-area

Usage

import { ScrollArea } from "@/components/ui/scroll-area";
<ScrollArea className="h-64">{recordings}</ScrollArea>

Anatomy

<ScrollArea>
  {children}
  <ScrollBar orientation="horizontal" />
</ScrollArea>

ScrollArea brings its own vertical ScrollBar. Add a horizontal one as a child when the content scrolls sideways.

Examples

Capped height

The root's height follows its content, so a cap goes on the viewport with viewportClassName (max-h-56). type="hover" also shows the thumb while the pointer is over the area, which suits a chat you read with the mouse on it.

Theming

Token or attributeMeaning
--scrollbar-thumb, --scrollbar-thumb-hoverThe thumb and its hover fill; light mode's is darker to register on porcelain
--scrollbar-thumb-ringThe thumb's 1 px inset ring
data-scrolling, data-hoveringOn the scrollbar while scrolling, and while the pointer is over the area
data-typeThe type, on the root

There is no track and no edge hairline: only the thumb reads.

Keyboard

KeyAction
TabFocuses the viewport when its content overflows
↑ ↓ ← →Scroll a step
Page Up Page DownScroll a page
Home EndScroll to the start or the end

Accessibility

The viewport is a native scroller, so wheel, trackpad and keyboard scrolling work as everywhere else. It takes focus only while its content overflows, and shows the focus ring then. Name the list inside it (aria-label="Chat messages"), not the scroll area.

API reference

ScrollArea

Every Base UI Scroll Area Root prop, plus:

Prop

Type

ScrollBar

Every Base UI Scroll Area Scrollbar prop. orientation is "vertical" by default.