Scroll Area
Thin-scrollbar wrapper with vertical, horizontal, or both overflow directions.
Installation
dgadd ships in @diffgazer/add on npm: pnpm add -D @diffgazer/add puts it on pnpm exec, and npx @diffgazer/add runs it without the install.
UI components require Tailwind CSS v4. Local copy mode imports src/styles/styles.css; package mode uses @diffgazer/ui CSS from the installed package.
Usage
Examples
Horizontal
Both Directions
Keyboard Region
Overlay
API Reference
ScrollArea
Accessibility
Keyboard Navigation
ScrollArea exposes role="region" whenever it has an accessible name (aria-label or aria-labelledby). When keyboardScrollable is also true, the named region becomes focusable and scrolls itself from keyboard events.
| Key | Action |
|---|---|
| ArrowUp / ArrowDown | Scrolls vertical or both-axis regions by 40px. |
| ArrowLeft / ArrowRight | Scrolls horizontal or both-axis regions by 40px. |
| PageUp / PageDown | Scrolls vertical regions by 80% of height; horizontal-only regions scroll by 80% of width. |
| Home / End | Moves to the start or end of each enabled scroll axis. |
Focusable region
Both directions
Notes
Orientation
3 modes via orientation prop — vertical (default), horizontal, or both. The thin bar comes from the library's own unlayered .scrollbar-thin utility, which deliberately outranks Tailwind v4's same-named built-in. The overlay prop applies to the vertical mode only.
Wrapper Only
Without overlay, ScrollArea is a pure wrapper that adds thin scrollbar styling and renders no visual output of its own. With overlay it renders one zero-height rail as the container's first DOM child (ahead of children) carrying the floating thumb — account for it in position-keyed styling of direct children (first:, nth-child, space-y-*).
Resting Thumb
The thumb is visible at rest (foreground at 35%) and strengthens on hover or focus-within, so overflow is signalled before the pointer arrives. Chromium and WebKit get that resting thumb from the ::-webkit-scrollbar tree, and the standard scrollbar-width/scrollbar-color pair is confined to engines without that pseudo-element: declaring both on one element makes Chromium fall back to a platform overlay scrollbar that stays invisible until you scroll. Override --scrollbar-thumb and --scrollbar-thumb-active on the ScrollArea or any ancestor to retune both steps — the overlay mode's floating thumb consumes the same two tokens, so one retune moves both presentations. Give the scroll container at least 1px of inset from a surrounding border so the track and the border do not read as one doubled edge.
Source
Install via CLI: pnpm exec dgadd add ui/scroll-area.
Highlighted source loads after this disclosure opens. Browse the source repository.