Scroll Area
A native scroll area for bounded overflow: popup lists, dialog bodies, wide tables, carousels and removable-chip rows. Never use it for a whole page or a reading column.
import { ScrollArea } from '@fairgarden/design/data/scroll-area'
The viewport is the browser's own scroller, and its scrollbar is the native one, colored by the scope: the thumb is the rule color, the track is the surface's own opaque color, and hovering the area steps the thumb to the heading ink. The scrollbar keeps the platform's width, and in forced colors it takes the system colors. Overflow is also shown by a hard 2 px rule on each side that has hidden content, never by a fade. The viewport is focusable whenever it scrolls; give it a label to make it a named region. Set focusable={false} when the content's own items are the focus stops and scroll themselves into view, as in a tab list.
Panel, wide and rail
Panel, wide and rail
panel is the default: it scrolls vertically, always keeps its scrollbar's gutter, so content that grows or filters never moves sideways, and it caps at half the viewport height; maxBlockSize sets another cap, such as the space a popup's positioner reports. wide scrolls horizontally and snaps to its content's snap points when near one; the Table uses it. rail scrolls horizontally and always snaps, for carousels; pair it with Prev and Next buttons and an "n of N" count. A horizontal scrollbar takes its room in the first paint whenever the content overflows, and an overlay scrollbar takes none. With fitContent={false} the content keeps the viewport's width and its children overflow it, so a carousel track's slide percentages resolve against the viewport.
Panel
Wide
Rail
Overflow edges
Each edge rule follows the viewport's scroll position through a scroll-driven animation, so it needs no script where the browser supports one. Elsewhere, a small effect writes data-overflow-x-start, data-overflow-x-end and data-has-overflow-x (or the y ones on a panel) on the root, and only there. The viewport names its scroll timeline --scroll-area-inline (wide, rail) or --scroll-area-block (panel). A composed component that reads it outside the root, as the Table's scroll cue does, scopes that name on its own element and sets the root's timeline-scope to none. --scroll-area-edge-start: none on the root hides the start edge, for a pinned column that draws its own; --scroll-area-overscroll-x and --scroll-area-overscroll-y set the viewport's scroll chaining, and --scroll-area-scroll-padding-inline its inline scroll padding, which insets the snapport. On wide and rail it defaults to 16 px (--size-px-3), the demos' item gap, so a snapped or focused item rests one gap inside the edge rule and the item before it clears the edge with no sliver showing; set it to your row's own gap or inset. The Carousel sets its start to 0 and its end to the bleed, so slides snap on the content line they rest on.
Removed from the Base UI Scroll Area
The Scroll Area no longer wraps Base UI's. These parts, props, attributes and variables are gone:
- Parts:
ScrollArea.Scrollbar,ScrollArea.ThumbandScrollArea.Corner, with the module'sscrollbar,thumbandcornerclasses. - Root props:
overflowEdgeThreshold,render, and the state-function forms ofclassNameandstyle. The root takes plaindivprops. - Attributes:
data-scrollingon every part;data-hoveringanddata-orientationon the scrollbar, anddata-orientationon the thumb;data-has-overflow-x,data-has-overflow-yanddata-overflow-{x,y}-{start,end}on the viewport, the content and the scrollbar. The root keeps its overflow attributes only where scroll-driven animations are missing. - CSS variables:
--scroll-area-corner-height,--scroll-area-corner-width,--scroll-area-thumb-height,--scroll-area-thumb-widthand--scroll-area-overflow-{x,y}-{start,end}, and the module's--scroll-area-gutterand--scroll-area-thumb. - Inline styles: the viewport's
overflow: scrolland the content'smin-width: fit-content, now plain module rules. The viewport'srole="presentation"is gone too.
In print
Overflow is removed: the content prints at full height and width, and the edge rules are hidden.
API Reference
A native scroll area: the browser’s own scrollbar, in the scope’s thumb
and track colors, and a hard --border-size-2 --role-rule edge on each
side with hidden content, never a fade [D21, D68, D207]. Content prints
at full height with the edges hidden. Don’t nest two scroll areas on the
same axis.
| Prop | Type | Description |
|---|---|---|
label | | Accessible name for the scrollable region. Given, the viewport becomes a
named |
contentClassName | | Class for the content wrapper, the layout box of the children. |
fitContent | |
|
focusable | |
|
kind | |
|
maxBlockSize | | The area’s maximum block size, a CSS length such as
|
primary | | Primary Radix scale: every part (thumb, edges, focus ring). Never defaulted; omitted, it inherits the scope [D133]. |
secondary | | Secondary Radix scale: unused by the scroll area. Never defaulted. |
viewportRef | | Ref to the scrolling viewport, e.g. to scroll it from Prev/Next buttons. |
scrollArea
type scrollArea = scrollAreaScrollAreaProps
Props for ScrollArea: div props for the root plus the kind and color axes.
type ScrollAreaProps = React.ClassAttributes<HTMLDivElement> &
React.HTMLAttributes<HTMLDivElement> & {
kind?: 'panel' | 'wide' | 'rail' | null;
primary?:
| 'ruby'
| 'olive'
| 'sage'
| 'slate'
| 'sand'
| 'gray'
| 'mauve'
| 'brown'
| 'bronze'
| 'gold'
| 'red'
| 'crimson'
| 'tomato'
| 'pink'
| 'plum'
| 'indigo'
| 'iris'
| 'violet'
| 'purple'
| null;
secondary?:
| 'ruby'
| 'olive'
| 'sage'
| 'slate'
| 'sand'
| 'gray'
| 'mauve'
| 'brown'
| 'bronze'
| 'gold'
| 'red'
| 'crimson'
| 'tomato'
| 'pink'
| 'plum'
| 'indigo'
| 'iris'
| 'violet'
| 'purple'
| 'amber'
| 'blue'
| 'cyan'
| 'grass'
| 'green'
| 'jade'
| 'lime'
| 'mint'
| 'orange'
| 'sky'
| 'teal'
| 'yellow'
| null;
label?: string;
viewportRef?: React.Ref<HTMLDivElement>;
contentClassName?: string;
maxBlockSize?: string | number;
focusable?: boolean;
fitContent?: boolean;
}Specification: DESIGN-SYSTEM.md §10.19 (scroll area) and D207 (native scrollbars).