Scroll Area
A wrapper for Base UI ScrollArea with vertical, horizontal, and dual-axis scrollbars, gradient fade via viewportCls, keepMounted, and overflow threshold control.
Orientation
Vertical — default, scrolls up/down
Horizontal — scrolls left/right
Both — vertical + horizontal + corner
Content
Prose — long text paragraph
Code block — monospace pre content
Options
keepMounted — scrollbar persists in DOM when not needed
Fade — mask-image gradient via viewportCls
overflowEdgeThreshold — overflow data attrs fire 20px before edge
Installation
npx shadcn@latest add @glrk-ui/scroll-areaIf you haven't set up the prerequisites yet, check out registry setup.
Usage
Basic (vertical)
import { ScrollAreaWrapper } from "@/components/ui/scroll-area"
<ScrollAreaWrapper className="h-64 w-full rounded-md border">
<div className="p-4">{/* tall content */}</div>
</ScrollAreaWrapper>Horizontal
<ScrollAreaWrapper orientation="horizontal" className="w-full rounded-md border">
<div className="flex gap-4 p-4">
{items.map(item => <Card key={item.id} className="w-48 shrink-0" />)}
</div>
</ScrollAreaWrapper>Both axes
Renders vertical + horizontal scrollbars and a Corner at their intersection:
<ScrollAreaWrapper orientation="both" className="h-64 w-96 rounded-md border">
<div style={{ width: "800px" }}>
{/* wide + tall content */}
</div>
</ScrollAreaWrapper>Keep scrollbar mounted
Prevents layout shift by keeping the scrollbar in the DOM even when content fits:
<ScrollAreaWrapper keepMounted className="h-64 rounded-md border">
{/* content */}
</ScrollAreaWrapper>Gradient fade
Use the viewportCls prop to apply a mask-image gradient via the viewport element:
<ScrollAreaWrapper
className="h-64 rounded-md border"
viewportCls="[mask-image:linear-gradient(to_bottom,transparent_0,black_2rem,black_calc(100%-2rem),transparent_100%)]"
>
{/* content */}
</ScrollAreaWrapper>Overflow edge threshold
Fire overflow data attributes before reaching the exact scroll edge:
<ScrollAreaWrapper overflowEdgeThreshold={20} className="h-64 rounded-md border">
{/* content */}
</ScrollAreaWrapper>Reference
ScrollAreaWrapper
Prop
Type
ScrollBar
Prop
Type