Skip to the page
Supply UI

Scroll area

In code: ScrollArea

A box that scrolls inside the page, with scrollbars drawn to match and a soft fade where there is more. The browser does the scrolling, so the wheel, touch, keys and find-in-page work as usual. stickToEnd follows new content, like a chat.

Preview

  • Invoice 1046.pdf84 KB
  • Invoice 1045.pdf84 KB
  • Invoice 1044.pdf84 KB
  • Invoice 1043.pdf84 KB
  • Invoice 1042.pdf84 KB
  • Invoice 1041.pdf84 KB

Use

The code of the preview above
import { List, ListItem, ScrollArea } from '@/components/ui';
import { FileText } from 'lucide-react';

<div className="ui-grow">
  <ScrollArea maxHeight="9rem" aria-label="Invoices" tabIndex={0}>
    <List>
      {[1046, 1045, 1044, 1043, 1042, 1041].map((n) => (
        <ListItem key={n}>
          <FileText />
          <span className="ui-grow ui-truncate">Invoice {n}.pdf</span>
          <span className="ui-mono ui-small ui-muted">84 KB</span>
        </ListItem>
      ))}
    </List>
  </ScrollArea>
</div>

This page as text, for an AI

Options

OptionTypeWhat it does
aria-label stringWhat the box holds, for screen readers: "Recent orders".
children ReactNodeWhat goes inside.
className stringMore classes on the outer element, for layout around it (margins, grid placement), not to restyle it.
maxHeight stringWhere it starts to scroll.
style CSSPropertiesInline styles on the outer element; for CSS variables such as a height, not for colours.
tabIndex numberIts place in the Tab order; 0 makes a scrolling box reachable from the keyboard.

It also takes the 281 attributes of the element or UI SDK part it draws: className, aria-label, events and the rest.

Without React

The same look on any HTML, with the classes ui-scroll + --max-height.

With the CSS in parts (/ui/css/), it needs these, besides the ones every page loads:

components/card.csscomponents/scroll-area-ratio-divider.cssparts/scroll-area.css

Showing things: states, do and don’t

A box that scrolls inside the page, with scrollbars drawn to match and a soft fade where there is more. stickToEnd follows new content, like a chat.

States. Lists, tables and boards have three more states besides their content: empty (Empty, with the first action inside), loading (Skeleton) and failed (Alert tone="danger"). A chosen row shows in ink, never in the brand colour.

Do

  • Put numbers, dates and codes in ui-mono (in a table cell, ui-num, which also aligns them).
  • Let a Table turn into blocks on a phone; give it scroll only when it is read down its columns.
  • Show a status in words and colour together (Badge tone="success" with "Paid"), never colour alone.

Don't

  • Don't put a card round a Table, List, Cells, Calendar or Empty: they draw their own box.
  • Don't truncate a name or a price to fit; let it wrap. Truncate only file names and addresses.
  • Don't use the status colours (success, warning, danger, info) for anything but those meanings.