GitHubGitHub
← All components
Layout / component

Scroll area

A native scroll container with the library’s thin scrollbar and edge fades that appear only while content is hidden past an edge.

VerticalHorizontalBothWithout fades
  • api-gatewaydeployed 2 hours ago
  • auth-servicedeployed 2 hours ago
  • billing-workerdeployed 2 hours ago
  • checkout-servicedeployed 2 hours ago
  • search-indexerdeployed 2 hours ago
  • notificationsdeployed 2 hours ago
  • image-resizerdeployed 2 hours ago
  • report-builderdeployed 2 hours ago
  • webhook-relaydeployed 2 hours ago
  • worker-07deployed 2 hours ago
<ScrollArea maxHeight="18rem" ariaLabel="Services">  <ul></ul></ScrollArea>

Installation

pnpm add @chanrg/4ui

Import the stylesheet once, at the root of your app:

import '@chanrg/4ui/styles.css';

Usage

import { ScrollArea } from '@chanrg/4ui';<ScrollArea maxHeight="18rem" ariaLabel="Services">  <ul></ul></ScrollArea>

Horizontal

Set orientation to horizontal for a wide row; the vertical axis is clipped instead of scrolled.

A single line that is far wider than its container, so the horizontal bar has something to do and the region can be scrolled sideways with the arrow keys.

<ScrollArea orientation="horizontal" ariaLabel="Deploy summary">  <p style="width:60rem"></p></ScrollArea>

API reference

Props

PropTypeDefaultDescription
orientationvertical | horizontal | bothverticalWhich axes may scroll. The other axis is clipped.
maxHeightstringAny CSS length — “18rem”, “40vh”. Omit to let the parent set the height.
shadowsbooleantrueFade the top and bottom edges while there is content past them.
ariaLabelstring'Scrollable content'Names the scrollable region.

CSS variables

VariableDescription
--4ui-surfacePrimary component surface.
--4ui-textPrimary foreground color.
--4ui-borderDefault control and panel border.
--4ui-border-strongScrollbar thumb; the track stays transparent.
--4ui-surfaceColour the edge fades blend into.

Accessibility

  • The viewport is a labelled region with tabindex="0", so arrow-key scrolling works and the region is announced.
  • Scrolling stays native: wheel physics, find-in-page, scrollIntoView, and selection auto-scroll are untouched.
  • Edge fades are pointer-events: none, so they never intercept a click meant for the content.
  • A ResizeObserver watches both the box and its content, so the fades stay correct when rows are added or the column narrows.

Dependencies

ResizeObserver