Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Scroll Area

FreeNew

Native scrolling with a thin overlay scrollbar that looks the same on every platform.

Installation

pnpm dlx shadcn@latest add @viewport/scroll-area

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above.

scroll-area-demo.tsx
import { ScrollArea } from "@/components/viewport/scroll-area";

const changes = [
  ["2.4.0", "Saved views can be shared with a team."],
  ["2.3.2", "Fixed a sort that ignored empty values."],
  ["2.3.1", "Imports now report which rows were skipped, and why."],
  ["2.3.0", "Column widths are remembered per view."],
  ["2.2.4", "Faster search across more than 50,000 contacts."],
  ["2.2.3", "Date filters respect the workspace time zone."],
  ["2.2.2", "Fixed a crash when a deal had no owner."],
  ["2.2.1", "Keyboard shortcuts for moving between records."],
  ["2.2.0", "Pipelines can have up to 12 stages."],
  ["2.1.3", "Exports include custom fields."],
  ["2.1.2", "Reduced the size of the first page load."],
  ["2.1.1", "Fixed the order of activity on merged contacts."],
];

export default function ScrollAreaDemo() {
  return (
    <div className="w-full max-w-sm overflow-hidden rounded-2xl border border-border bg-card">
      <p className="border-b border-border px-4 py-3 text-sm font-medium">Release notes</p>
      <ScrollArea label="Release notes" className="h-56">
        <ul className="divide-y divide-border">
          {changes.map(([version, note]) => (
            <li key={version} className="flex gap-3 px-4 py-2.5 text-sm">
              <span className="w-10 shrink-0 font-mono text-xs leading-5 text-muted-foreground">{version}</span>
              <span>{note}</span>
            </li>
          ))}
        </ul>
      </ScrollArea>
    </div>
  );
}

Props

PropTypeDefault
orientation"vertical" | "horizontal" | "both"

Which way the content can scroll.

"vertical"
labelstring

Names the region and makes it focusable, so it can be scrolled with the keyboard. Set it when the area holds no focusable elements.

—

Accessibility

  • Scrolling stays native: touch, wheel and keyboard all work.
  • With a label the region is focusable and named, so it can be scrolled from the keyboard.
  • The bar fades without moving under reduced motion.