Xzero UI
Pro library

Scroll area

A native scroll container with thin overlay scrollbars and edge fades that appear only when content overflows.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui/scroll-area
Live · keyboard ready

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui/scroll-area

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { ScrollArea } from "@/components/xzero/scroll-area/scroll-area";

export function ActivityPanel({ events }: { events: { id: string; text: string }[] }) {
  return (
    <ScrollArea maxHeight={320} label="Recent activity">
      <ul>{events.map(event => <li key={event.id}>{event.text}</li>)}</ul>
    </ScrollArea>
  );
}

Examples

Horizontal strip with snap

<ScrollArea orientation="horizontal" snap="x mandatory" label="Templates">
  <div style={{ display: "flex", gap: 12 }}>
    {templates.map(item => <TemplateCard key={item.id} {...item} style={{ scrollSnapAlign: "start" }} />)}
  </div>
</ScrollArea>

API reference

ScrollArea

A native scroll container with thin overlay scrollbars that appear while scrolling or on hover, and edge fades that grow with the content left beyond each edge.

PropTypeDefaultDescription
orientation"vertical" | "horizontal" | "both""vertical"Axes that scroll.
fadenumber28Length of the edge fade in px. 0 turns the fades off.
scrollbars"auto" | "always""auto""auto" shows scrollbars while scrolling or hovering; "always" keeps them visible when content overflows.
hideDelaynumber900How long scrollbars linger after scrolling stops, in ms.
maxHeightCSSProperties["maxHeight"]–Maximum viewport height, for vertical areas that grow with their content.
snapCSSProperties["scrollSnapType"]–Passed to the viewport's scroll-snap-type, for example "x mandatory". Children set their own scroll-snap-align.
labelstring–Accessible name. The viewport becomes a labelled region.
wheelToHorizontalbooleantrueTurns vertical wheel movement into horizontal scrolling for horizontal areas.
viewportClassNamestring–Extra class on the scrolling viewport.
viewportStyleCSSProperties–Inline style on the viewport.
viewportRefRef<HTMLDivElement>–The scrolling element, for programmatic scrolling.
onScroll(event: UIEvent<HTMLDivElement>) => void–Viewport scroll handler.
onEdgeChange(edges: ScrollAreaEdges) => void–Called when content starts or stops extending past an edge: { top, bottom, left, right }.
...propsHTMLAttributes<HTMLDivElement>–Forwarded to the root, including ref and className.

Keyboard interactions

KeysAction
TabThe viewport is focusable (tabIndex 0).
Arrow keys / Page Up / Page Down / Home / End / SpaceScroll natively once the viewport has focus.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Also in expand

Guidance for AI tools

Scroll area: A native scroll container with thin overlay scrollbars and edge fades that appear only when content overflows. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components