Scroll Area
NewAugments native scroll functionality with auto, hover, and always visibility modes, scrollbar variants, gutter reserve, keyboard navigation, and high-contrast support.
$ pnpm dlx shadcn@latest add @byphongphan/scroll-area@byphongphan in components.jsonInstallation
Install the following dependencies:
$ pnpm add @base-ui/react class-variance-authority@byphongphan in components.jsonCopy and paste the scroll-area component into your project.
Update the import paths to match your project setup.
Usage
Examples
Horizontal Scrolling
ScrollArea with horizontal orientation for scrolling horizontal photo feeds, tag carousels, or metric cards.
Minimal Hairline
Ultra-compact zero-margin scrollbar for dense data tables, code editors, and side panels.
Bordered Track
Defined track border separating the scroll gutter from overflowing content.
Floating Island
Elevated floating thumb with soft shadow and inset padding for card surfaces and modal overlays.
Scroll Fade Mask
Top and bottom content fade masks indicating offscreen overflowing content.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
type | "hover" | "auto" | "always" | "hover" | Visibility behavior for the scrollbars. |
variant | "default" | "minimal" | "bordered" | "floating" | "default" | Visual aesthetic variant for the scrollbar track and thumb. |
size | "sm" | "default" | "lg" | "default" | Thickness of the scrollbar track (4px, 6px, or 10px). |
orientation | "vertical" | "horizontal" | "both" | "none" | "both" | Orientation of the automatically managed built-in scrollbars. |
scrollbarGutter | boolean | "auto" | "stable" | false | Controls reserve gutter spacing to eliminate layout shifts. |
scrollFade | boolean | false | Adds smooth mask fade gradient at the overflowing edges. |
overscrollContain | boolean | false | Prevents scroll chaining to parent containers on boundary edges. |
fill | boolean | false | Stretches viewport content container to 100% width and height. |
clampContentMinWidth | boolean | true | Constrains content min-width: 0 to enable responsive resizing. |
classNameViewport | string | undefined | Additional CSS class names applied directly to the Viewport element. |
tabIndex | number | 0 | Keyboard focus tab index for keyboard-navigable scrolling. |
role | string | "region" | Accessible ARIA role for screen-reader region identification. |