ToroUI

Scroll Area

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>
  )
}

Anatomy

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>

Examples

Vertical scroll

<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>

Horizontal scroll

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>

Fixed-height list

<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>

API Reference

ScrollArea

The root container. Renders a relatively positioned wrapper that contains the viewport, scrollbar, and corner elements.

PropTypeDefault
classNamestring
childrenReactNode

Accepts all props from Base UI's ScrollArea.Root.

ScrollBar

A styled scrollbar track with a thumb indicator. Automatically included in ScrollArea for vertical scrolling. Add an additional ScrollBar for horizontal content.

PropTypeDefaultDescription
orientation"vertical" | "horizontal""vertical"The scrollbar axis.
classNamestring

Accepts all props from Base UI's ScrollArea.Scrollbar.