Scrolling
Native scroll container with thin overlay scrollbars and proportional edge fades.
import { ScrollArea } from '@uthereal/ui/scroll-area'Scroll area playground
Overview
ScrollArea wraps content that can outgrow its container, such as activity lists, side panels, logs, and horizontal strips. Scrolling stays native so wheel inertia, touch momentum, keyboard scrolling, and CSS scroll snap behave as the platform expects. Thin overlay scrollbars replace native platform bars, and each edge fades in proportion to the content hidden past it.
Use ScrollArea when a bounded region scrolls independently of the page. Let the page scroll everywhere else. Pair it with panels when each pane needs its own scrollable body, or use accordion and expandable text to collapse sections instead of scrolling them.
Usage
import { ScrollArea } from '@uthereal/ui/scroll-area'
export function ActivityFeed({ entries }: { entries: Entry[] }) {
return (
<ScrollArea label="Recent activity" maxHeight={320}>
{entries.map((entry) => (
<ActivityRow key={entry.id} entry={entry} />
))}
</ScrollArea>
)
}Set maxHeight to let the viewport grow with its content up to a pixel limit before scrolling. Omit maxHeight when the parent container supplies a definite height, such as a pane inside panels. Pass onScroll to listen to viewport scroll events, onEdgeChange to observe overflow changes at each edge, and viewportRef to scroll programmatically.
Examples
Orientation
vertical scrolls down and wraps content to the container width. horizontal keeps content on one line and maps vertical mouse-wheel movement sideways while room remains. both scrolls freely on both axes.
Scrollbars and fades
scrollbars="always" keeps overlay bars visible whenever content overflows. edgeFade accepts boolean | number (0–120 px): false (or 0) removes the gradient masks for hard borders, and a number sets an exact maximum fade length in pixels.
Scroll behavior
| Prop / value | Behavior |
|---|---|
edgeFade={true} | Proportional edge masks up to theme.tokens.fadeSize (28px default). Grows smoothly from 0px on edge. |
edgeFade={number} | Exact maximum fade length in pixels (1–120), overriding theme.tokens.fadeSize. 0 disables fades. |
edgeFade={false} | Disables edge fades and omits mask compositing on the viewport. |
scrollbars="auto" | Shows bars while scrolling, dragging, or hovering with a fine pointer; hides after hideDelay (900ms). |
snap | Applies CSS scroll-snap-type (none or x/y/both with mandatory/proximity); paused on drag. |
wheelToHorizontal | In horizontal mode, converts vertical wheel deltas into horizontal scroll until an end edge is reached. |
| Track click | Pressing the track outside the thumb pages 90% of the viewport toward the pointer. |
API reference
These serializable arguments and defaults come directly from the component schema.
| Argument | Type / default | Description |
|---|---|---|
orientation | vertical | horizontal | bothDefault: "vertical" | Which axes scroll. vertical wraps content to the width; horizontal keeps it on one line; both scrolls freely. |
maxHeight | integer— | Grow with the content up to this many pixels, then scroll. Omit it when the container gives the area a height. |
scrollbars | auto | alwaysDefault: "auto" | auto shows the scrollbars while scrolling or hovering; always keeps them visible whenever the content overflows. |
edgeFade | boolean | integerDefault: true | Fade the edges where more content is hidden. Each fade grows with the hidden distance. true uses theme.tokens.fadeSize (28 pixels, as Arc), false turns the fades off, and a number is an exact length in pixels up to 120. |
hideDelay | numberDefault: 900 | How long auto scrollbars linger after scrolling stops, in milliseconds (900 by default, as Arc), before they fade out. |
snap | none | x mandatory | x proximity | y mandatory | y proximity | both mandatory | both proximityDefault: "none" | CSS scroll snapping of the viewport, e.g. "x mandatory" for a row of cards; children set their own snap alignment. |
wheelToHorizontal | booleanDefault: true | In a horizontal area, turn vertical wheel movement sideways while there is room to scroll, so the page still scrolls at the ends. |
labelRequired | string— | Names the area for assistive technology; required. When the content overflows, the area becomes a region with this name that keyboard users can focus and scroll. |
recipe | studio | softDefault: "studio" | Visual treatment. Both recipes share the same behavior. |
theme | ScrollAreaTheme— | Color mode and tokens: foreground (the thumb is 30% of it at rest, 46% when active), the focus ring and fadeSize. |
motion | none | subtle | expressiveDefault: "subtle" | Scrollbar fade preset. none, or a system reduced-motion preference, shows and hides them instantly. |
dir | ltr | rtl— | Reading direction. Omit it to inherit the page direction; the vertical scrollbar sits at the inline end. |
React integration
| Prop | Purpose |
|---|---|
children | Scrolling content rendered inside the viewport. |
ref | Forwarded to the root <div>. |
viewportRef | Forwarded to the scrolling viewport <div>. |
viewportClassName | Class appended to the scrolling viewport after the base viewport class. |
viewportStyle | Inline styles applied to the scrolling viewport after snap (drag still suspends scrollSnapType). |
onScroll(event) | Fires on every viewport scroll event, not on the root element. |
onEdgeChange(edges) | Fires when hidden overflow changes on any physical edge (ScrollAreaEdges: top, bottom, left, right). |
preset | Application defaults overridden by explicit instance props. |
tokens | CSS custom properties (--ui-*) applied after the typed theme. |
className, style | Applied to the root <div>, for example to set a fixed height. |
| Native attributes | Standard div attributes (id, aria-*, data-*) forwarded to the root <div>, excluding onScroll. |
Keyboard & accessibility
| Key | Interaction |
|---|---|
Tab | Focus the viewport when its content overflows. |
ArrowUp, ArrowDown | Scroll vertically; ArrowLeft and ArrowRight scroll horizontally when enabled. |
PageUp, PageDown, Space | Scroll one viewport page. |
Home, End | Jump to the start or end of the scrollable content. |
When content overflows an enabled axis, the viewport joins the tab order (tabIndex={0}) and exposes role="region" named by the required label prop. Content that fits is neither focusable nor announced as a region. The keyboard focus outline sits on the root element so edge fade masks never clip it. Overlay scrollbars are pointer-only (aria-hidden) and set touch-action: none on both track and thumb so touch dragging moves the viewport rather than panning the page.
In right-to-left layouts (dir="rtl" or inherited from the page), the vertical bar sits at the inline end (left), horizontal fades and wheelToHorizontal mirror automatically, and onEdgeChange reports physical left and right sides. Under forced-colors: active, thumbs switch to ButtonText and focus rings use Highlight.
Motion and theming
Overlay bars appear in 160ms when scrolling, dragging, or hovering, linger for hideDelay (900ms default) after scrolling or dragging stops, and fade out over 480ms. The 5px thumb pill (minimum length 28px) thickens to 7px and darkens from 30% to 46% foreground ink only under @media (hover: hover) and (pointer: fine). Thumb sizing, thumb transforms, and fade distances write directly to the DOM with zero per-frame React re-renders.
| Motion setting | Scrollbar fade and thumb sizing | Track paging |
|---|---|---|
subtle, expressive | 160ms show, 480ms hide, smooth pill resize. | Smooth scroll. |
none | Immediate (0ms, transition: none). | Instant jump. |
prefers-reduced-motion: reduce | Immediate (0ms, transition: none). | Instant jump. |
theme accepts mode, accent, and three tokens: foreground (--ui-text, mixed at 30% resting and 46% active), focusRing (--ui-focus-ring), and fadeSize (--ui-scroll-area-fade-size, 0–120px, default 28px). An application-wide UtherealProvider supplies defaults.
Composition
In an agent composition, ScrollArea is a container that accepts up to 100 child element IDs in children. Set maxHeight unless the surrounding container gives the area a fixed height. See Building with agents.
{
"type": "ScrollArea",
"props": { "label": "Recent activity", "maxHeight": 320 },
"children": ["activity-list"]
}