Scroll Area
A region that scrolls inside its box, with thin bars that appear when you hover and fade away after. Use it for long lists in a fixed panel, and for galleries that run past the edge. Built on Radix, with shadcn's API.
Install
npx shadcn@latest add @nelumbo/scroll-areaVertical list
A fixed-height box with a list inside. The bar appears on hover, or while you scroll with the wheel or keys. Tab to the list to scroll it from the keyboard: arrow keys, Page Up and Page Down, Home and End.
Horizontal gallery
Make the content wide and give the area a horizontal bar: add <ScrollBar orientation="horizontal" />. Leave a little room at the bottom so the bar does not sit on the cards.
Both directions
Content that is wide and tall gets both bars, with a small corner where they meet. Scrolling works with the wheel, trackpad, the bars or the keyboard.
Fade edges
The fade prop softens the edge where content continues. An edge fades only while there is more content past it, so the first and last items are never dimmed. Scroll to the middle to see both edges.
Usage
import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"// shadcn's API<ScrollArea className="h-72 w-48 rounded-md border"> <div className="p-4">…</div></ScrollArea>// Horizontal gallery<ScrollArea className="w-96"> <div className="flex w-max gap-4 p-4">…</div> <ScrollBar orientation="horizontal" /></ScrollArea>// Nelumbo: soft edge fades that show only where there is more to see<ScrollArea fade aria-label="Tags" className="h-72">…</ScrollArea>Props
| Prop | Type | Default | Radix's own props (type, scrollHideDelay, dir) work as is |
|---|---|---|---|
ScrollArea fade | boolean | false | Soft fades at the edges that have more content past them |
ScrollArea type | "auto" | "always" | "scroll" | "hover" | "hover" | Nelumbo default: bars show on hover and fade out. Use always to keep them |
ScrollArea scrollHideDelay | number | 600 | Milliseconds before the bars fade after the pointer leaves |
ScrollArea aria-label | string | Names the scrollable region (the viewport gets role region) | |
ScrollBar orientation | "vertical" | "horizontal" | "vertical" | A vertical bar is always there unless you pass one yourself |