UI

Scrolling

Native scroll container with thin overlay scrollbars and proportional edge fades.

import { ScrollArea } from '@uthereal/ui/scroll-area'

Scroll area playground

Loading interactive preview…

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 / valueBehavior
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).
snapApplies CSS scroll-snap-type (none or x/y/both with mandatory/proximity); paused on drag.
wheelToHorizontalIn horizontal mode, converts vertical wheel deltas into horizontal scroll until an end edge is reached.
Track clickPressing 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.

ArgumentType / defaultDescription
orientationvertical | horizontal | bothDefault: "vertical"Which axes scroll. vertical wraps content to the width; horizontal keeps it on one line; both scrolls freely.
maxHeightinteger—Grow with the content up to this many pixels, then scroll. Omit it when the container gives the area a height.
scrollbarsauto | alwaysDefault: "auto"auto shows the scrollbars while scrolling or hovering; always keeps them visible whenever the content overflows.
edgeFadeboolean | integerDefault: trueFade 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.
hideDelaynumberDefault: 900How long auto scrollbars linger after scrolling stops, in milliseconds (900 by default, as Arc), before they fade out.
snapnone | 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.
wheelToHorizontalbooleanDefault: trueIn a horizontal area, turn vertical wheel movement sideways while there is room to scroll, so the page still scrolls at the ends.
labelRequiredstring—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.
recipestudio | softDefault: "studio"Visual treatment. Both recipes share the same behavior.
themeScrollAreaTheme—Color mode and tokens: foreground (the thumb is 30% of it at rest, 46% when active), the focus ring and fadeSize.
motionnone | subtle | expressiveDefault: "subtle"Scrollbar fade preset. none, or a system reduced-motion preference, shows and hides them instantly.
dirltr | rtl—Reading direction. Omit it to inherit the page direction; the vertical scrollbar sits at the inline end.

React integration

PropPurpose
childrenScrolling content rendered inside the viewport.
refForwarded to the root <div>.
viewportRefForwarded to the scrolling viewport <div>.
viewportClassNameClass appended to the scrolling viewport after the base viewport class.
viewportStyleInline 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).
presetApplication defaults overridden by explicit instance props.
tokensCSS custom properties (--ui-*) applied after the typed theme.
className, styleApplied to the root <div>, for example to set a fixed height.
Native attributesStandard div attributes (id, aria-*, data-*) forwarded to the root <div>, excluding onScroll.

Keyboard & accessibility

KeyInteraction
TabFocus the viewport when its content overflows.
ArrowUp, ArrowDownScroll vertically; ArrowLeft and ArrowRight scroll horizontally when enabled.
PageUp, PageDown, SpaceScroll one viewport page.
Home, EndJump 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 settingScrollbar fade and thumb sizingTrack paging
subtle, expressive160ms show, 480ms hide, smooth pill resize.Smooth scroll.
noneImmediate (0ms, transition: none).Instant jump.
prefers-reduced-motion: reduceImmediate (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"]
}

On this page