A custom scrollable container with styled scrollbars that replace native browser scrollbars.
A scroll area wraps content in a custom scrollable viewport with minimal, styled scrollbars. Built on Base UI's ScrollArea primitive, it provides a consistent cross-browser scrolling experience while remaining keyboard accessible.
import { ScrollArea } from "@/components/ui/scroll-area"
export default function ScrollAreaDemo() {
const items = Array.from({ length: 50 }, (_, i) => `Item ${i + 1}`)
return (
<ScrollArea className="h-72 w-48 rounded-md border p-4">
<div className="space-y-2">
{items.map((item) => (
<div key={item} className="text-sm">
{item}
</div>
))}
</div>
</ScrollArea>
)
}
import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"<ScrollArea className="h-72 w-48 rounded-md border">
<div className="p-4">
{/* Scrollable content */}
</div>
</ScrollArea><ScrollArea className="h-72 w-48 rounded-md border">
<div className="p-4">
{Array.from({ length: 50 }, (_, i) => (
<div key={i} className="py-1 text-sm">Item {i + 1}</div>
))}
</div>
</ScrollArea>Add a ScrollBar with orientation="horizontal" alongside horizontally overflowing content.
<ScrollArea className="w-96 rounded-md border">
<div className="flex gap-4 p-4">
{Array.from({ length: 20 }, (_, i) => (
<div key={i} className="w-40 shrink-0 rounded-md border p-4">
Card {i + 1}
</div>
))}
</div>
<ScrollBar orientation="horizontal" />
</ScrollArea><ScrollArea className="h-48 rounded-md border">
<div className="p-4 space-y-2">
<h4 className="mb-4 text-sm font-medium">Tags</h4>
{["React", "Vue", "Svelte", "Angular", "Solid", "Qwik", "Astro", "Next.js", "Nuxt", "Remix"].map((tag) => (
<div key={tag} className="text-sm">{tag}</div>
))}
</div>
</ScrollArea>The root container. Renders a relatively positioned wrapper that contains the viewport, scrollbar, and corner elements.
| Prop | Type | Default |
|---|---|---|
className | string | — |
children | ReactNode | — |
Accepts all props from Base UI's ScrollArea.Root.
A styled scrollbar track with a thumb indicator. Automatically included in ScrollArea for vertical scrolling. Add an additional ScrollBar for horizontal content.
| Prop | Type | Default | Description |
|---|---|---|---|
orientation | "vertical" | "horizontal" | "vertical" | The scrollbar axis. |
className | string | — |
Accepts all props from Base UI's ScrollArea.Scrollbar.