ScrollArea
A flat Y2K-styled scroll area built on top of Radix UI's ScrollArea
primitive. It provides a thick navy border, a white viewport, and a custom
pastel-blue scrollbar with a thick navy outline.
scroll-area-demo.app
Installation
terminal.sh
npx y2kui@latest add scroll-areaUsage
import {
ScrollArea,
ScrollAreaViewport,
Scrollbar,
ScrollThumb,
ScrollCorner,
} from "@/components/ui/scroll-area"
export function Example() {
return (
<ScrollArea className="h-48 w-80">
<ScrollAreaViewport>
{/* Your scrollable content goes here */}
<div className="space-y-2 p-4">
{items.map((item) => (
<div key={item.id}>{item.label}</div>
))}
</div>
</ScrollAreaViewport>
<Scrollbar orientation="vertical" />
</ScrollArea>
)
}Props
ScrollArea
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Additional CSS classes to merge onto the root container. |
type | "auto" | "always" | "scroll" | "hover" | "hover" | Describes the nature of the scrollbar visibility. |
scrollHideDelay | number | 600 | Duration (in ms) before the scrollbar hides when type is `"hover"`. |
dir | "ltr" | "rtl" | — | Reading direction of the scroll area. |
ScrollAreaViewport
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Additional CSS classes to merge onto the viewport. |
Scrollbar
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Additional CSS classes to merge onto the scrollbar track. |
orientation | "vertical" | "horizontal" | "vertical" | The orientation of the scrollbar. |
ScrollThumb
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Additional CSS classes to merge onto the scrollbar thumb. |
ScrollCorner
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Additional CSS classes to merge onto the corner element. |
Examples
Horizontal scroll
Also supports horizontal scrolling via the orientation prop.
scroll-area-horizontal-demo.app
Always visible scrollbar
Set type="always" to keep the scrollbar always visible.
scroll-area-always-demo.app