1. Documentation
  2. Layout
  3. Scroll Area
ReadmenpmGitHub
  • Introduction
  • Installation
  • Theming
  • Icons
  • Accordion
  • Card
  • Scroll Area
  • Separator
  • Sidebar
  • Field
  • Label
  • Input
  • Textarea
  • Number Field
  • OTP Field
  • Select
  • Combobox
  • Checkbox
  • Radio
  • Switch
  • Slider
  • Toggle
  • Calendar
  • Date Picker
  • File Upload
  • Button
  • Copy Button
  • Dropdown
  • Command
  • Tabs
  • Breadcrumb
  • Pagination
  • Tree
  • Table
  • Data Table
  • Stat
  • Timeline
  • Avatar
  • Status Bar
  • Badge
  • Meter
  • Empty
  • Skeleton
  • Spinner
  • Toast
  • Dialog
  • Sheet
  • Popover
  • Tooltip
  • Text
  • Kbd
  • Code Block
  • Utilities
  • Design rules

Scroll Area

A scroll container with a real scrollbar instead of the browser's, and an edge fade that says there is more.

Loading documentation…

Card< PreviousSeparatorNext >

Powered by heyo

On this page

UsageThe edge fadeBoth axesScrollArea or heyo-scrollbar?PropertiesScrollArea.Scrollbar
  • deploy-400 · 1m ago
  • deploy-3ff · 2m ago
  • deploy-3fe · 3m ago
  • deploy-3fd · 4m ago
  • deploy-3fc · 5m ago
  • deploy-3fb · 6m ago
  • deploy-3fa · 7m ago
  • deploy-3f9 · 8m ago
  • deploy-3f8 · 9m ago
  • deploy-3f7 · 10m ago
  • deploy-3f6 · 11m ago
  • deploy-3f5 · 12m ago
  • deploy-3f4 · 13m ago
  • deploy-3f3 · 14m ago
  • deploy-3f2 · 15m ago
  • deploy-3f1 · 16m ago
  • deploy-3f0 · 17m ago
  • deploy-3ef · 18m ago
<ScrollArea maxHeight="12rem" viewportClassName="p-3"><ul className="m-0 flex list-none flex-col gap-1 p-0 text-sm">  {deployments.map((deployment) => (    <li key={deployment.sha} className="text-heyo-subtle">{deployment.sha}</li>  ))}</ul></ScrollArea>

ScrollArea replaces the browser's scrollbar with real elements: a 6px overlay thumb that appears while you hover or scroll and fades out afterwards, the same on every operating system. A dense pane does not carry a permanent grey gutter, and the layout does not shift when content starts overflowing.

Usage

tsx
import { ScrollArea } from "@heyo-sh/heyo-ui";<ScrollArea maxHeight="18rem" viewportClassName="p-3">  {rows}</ScrollArea>;

Something has to bound the height or there is nothing to scroll: set maxHeight, or put a height on viewportClassName.

Padding goes on the viewport

Put padding on viewportClassName, not on the root. Padding on the root sits outside the scrolling box, which leaves the thumb floating away from the edge and clips the first row.

The edge fade

Content fades out where it runs past an edge, so a cut-off list reads as more below rather than as the end of the list. The fade only exists on edges that actually have more content behind them, and it follows whichever axes orientation enables. Turn it off with fade={false}.

  • No fade — row 1
  • No fade — row 2
  • No fade — row 3
  • No fade — row 4
  • No fade — row 5
  • No fade — row 6
  • No fade — row 7
  • No fade — row 8
  • No fade — row 9
  • No fade — row 10
  • No fade — row 11
  • No fade — row 12
<ScrollArea maxHeight="8rem" fade={false} viewportClassName="p-3">…</ScrollArea>

Both axes

orientation="both" draws a scrollbar on each axis and masks both edges at once. Wide tables and log output are the usual cases.

[12:04:11] build  ▸ bundling worker for production (esbuild 0.25)
[12:04:14] build  ▸ 412 modules, 184 kB gzip
[12:04:14] deploy ▸ uploading to fra1, waw1, iad1
[12:04:19] deploy ▸ acme-api is live at https://acme-api.heyo.sh
[12:04:19] deploy ▸ done in 8.2s
<ScrollArea orientation="both" maxHeight="9rem" viewportClassName="p-3"><pre className="m-0 text-sm">{log}</pre></ScrollArea>

ScrollArea or heyo-scrollbar?

They are not interchangeable.

  • ScrollArea is for designed surfaces — panes, cards, log views, popups — where the scrollbar is part of the composition and the fade carries meaning.
  • heyo-scrollbar, a plain utility, restyles the native scrollbar: thin, translucent, no track, no buttons. No extra DOM, no JavaScript, and it survives anything a scroll container cannot wrap — a <table> wrapper, a dialog body, the sidebar.
tsx
<div className="max-h-72 overflow-y-auto heyo-scrollbar">{rows}</div>

Properties

orientation"vertical" | "horizontal" | "both"optional

Which axes get a scrollbar. It defaults to vertical.

maxHeightstringoptional

Shorthand for a bounded viewport, for example "18rem". Without it — or a height on viewportClassName — nothing scrolls.

fadebooleanoptional

Fades content at an overflowing edge. It defaults to true and applies to whichever axes orientation enables.

viewportClassNamestringoptional

Class for the inner scrolling element. Padding belongs here.

classNamestringoptional

Class for the root — radius, ring, width.

childrenReactNodeoptional

The scrolling content.

ScrollArea.Scrollbar

Rendered for you. Place it yourself only when you need a scrollbar somewhere unusual — outside the padded viewport, say.

orientation"vertical" | "horizontal"optional

The axis this scrollbar controls.