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
Use
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>Options
| Option | Type | What it does |
|---|---|---|
aria-label | string | What the box holds, for screen readers: "Recent orders". |
children | ReactNode | What goes inside. |
className | string | More classes on the outer element, for layout around it (margins, grid placement), not to restyle it. |
maxHeight | string | Where it starts to scroll. |
style | CSSProperties | Inline styles on the outer element; for CSS variables such as a height, not for colours. |
tabIndex | number | Its 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.cssShowing 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
Tableturn into blocks on a phone; give itscrollonly 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,CalendarorEmpty: 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.