Scroll Area
A custom scrollable container with styled scrollbars.
A scrollable area with custom-styled scrollbars.
Usage
import { ScrollArea } from "@delphi/ui";
export function Example() {
return (
<ScrollArea className="h-72 w-48 rounded-md border">
<div className="p-4">
{/* Long content here */}
</div>
</ScrollArea>
);
}
Critical: Height Requirements
ScrollArea's internal Viewport uses h-full w-full, which means it needs an explicit height on the ScrollArea container to work properly.
Inside overflow-hidden containers
When using ScrollArea inside components with overflow-hidden (like DropdownMenuSubContent, PopoverContent, Command), you must use an explicit fixed height:
// ✅ CORRECT - explicit height
<DropdownMenuSubContent className="p-0">
<ScrollArea className="h-72">
<div className="p-1">{/* content */}</div>
</ScrollArea>
</DropdownMenuSubContent>
// ❌ WRONG - h-auto with max-height doesn't work
<DropdownMenuSubContent className="p-0">
<ScrollArea className="h-auto max-h-72">
<div className="p-1">{/* content */}</div>
</ScrollArea>
</DropdownMenuSubContent>
Why? The Viewport's h-full needs a real pixel height to reference. When the parent has overflow-hidden, using h-auto max-h-* doesn't give the Viewport a concrete height to fill, so scrolling breaks.
API Reference
| Prop | Type | Default | Description |
|---|---|---|---|
type | "auto" | "always" | "scroll" | "hover" | "hover" | When scrollbar is visible |
scrollHideDelay | number | 600 | Delay before hiding scrollbar in ms |
dir | "ltr" | "rtl" | - | Reading direction |
Use ScrollArea for custom-styled scrollbars that match your design
Set an explicit fixed height (e.g.,
h-72) — especially inside overflow-hidden containersConsider
type="always" to show scrollbar presenceTest keyboard scrolling and focus behavior
Ensure content is reachable via keyboard navigation
Use
h-auto max-h-* inside overflow-hidden containers — it won't scrollUse ScrollArea when native scrolling is sufficient
Nest multiple scroll areas — it's confusing
Hide scrollbars completely — users need visual feedback
Make scroll areas too small to be usable