sc1m/design
ComponentsScroll Area

Scroll Area

Scroll Area component built on Base UI, styled with sc1m tokens.

StableBase UI

Live preview

Installation

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

This also merges the token layer and installs src/lib/cn.ts plus @base-ui/react. For the manual route — prerequisites, components.json, and app-level setup — see Installation.

Usage

import {
  ScrollArea,
  ScrollAreaViewport,
  ScrollAreaScrollbar,
  ScrollAreaThumb,
  ScrollAreaContent,
  ScrollAreaCorner,
} from "@/components/ui/scroll-area";

Composition

Every part is a separate export. ScrollArea owns state; the rest are presentational and must appear in this order.

ScrollArea├── ScrollAreaViewport└── ScrollAreaScrollbar    └── ScrollAreaThumb

Example

The preview above, with its source. This is the demo module verbatim, so the code and the thing it renders cannot drift apart.

<ScrollArea className="h-48 w-64 rounded-md border border-line">
  <ScrollAreaViewport>
    <div className="p-4 text-sm text-fg">
      {Array.from({ length: 20 }, (_, i) => (
        <p key={i} className="py-1">
          Row {i + 1}
        </p>
      ))}
    </div>
  </ScrollAreaViewport>
  <ScrollAreaScrollbar orientation="vertical">
    <ScrollAreaThumb />
  </ScrollAreaScrollbar>
</ScrollArea>

API reference

Each part forwards every prop of its Base UI counterpart; the tables list the ones declared on the part itself. See Base UI's reference for the inherited element props.

ScrollArea

PropTypeDefaultDescription
overflowEdgeThresholdnumber | Partial<{ xStart: number; xEnd: number; yStart: number; yEnd: number; }>0The threshold in pixels that must be passed before the overflow edge attributes are applied.

ScrollAreaScrollbar

PropTypeDefaultDescription
orientation'vertical' | 'horizontal''vertical'Whether the scrollbar controls vertical or horizontal scroll.
keepMountedbooleanfalseWhether to keep the HTML element in the DOM when the viewport isn't scrollable.

Accessibility

Behaviour, focus management, and ARIA wiring come from Base UI's Scroll Area — see its reference for the full keyboard map.

Design tokens

The component reads semantic tokens only — no raw colour, radius, or duration appears in its source. Override the token, not the component.

TokenApplied to
--brand-radius-smScrollAreaThumb
--line-strongScrollAreaThumb

Source

src/components/ui/scroll-area/scroll-area.tsx — no next/* imports, so it drops into any React 19 + Tailwind v4 app.