Tinyrack

ScrollArea

A custom scrollbar surface that preserves native scrolling.

Contract

This Tinyrack wrapper preserves Base UI behavior, React 19 refs, native scrolling, and the render contract. Playground controls cover vertical, horizontal, and two-axis content.

Install

pnpm add @tinyrack/ui

Scroll inside the code area to read long lines.

Styles

@import '@tinyrack/ui/components/scroll-area.css';

Scroll inside the code area to read long lines.

Imports

import { TRScrollArea } from '@tinyrack/ui/components/scroll-area';

Scroll inside the code area to read long lines.

Playground

Usage

Examples

Two-axis overflow permalink

Render one scrollbar for each overflowing axis and include Corner where the tracks meet.

Horizontal overflow permalink

Render only the horizontal track when content overflows on the inline axis. Native touch, trackpad, wheel, and keyboard scrolling remain available on Viewport.

Auto-hiding scrollbar permalink

Set autoHide to hide idle tracks. Hover, scroll, or focus the viewport to reveal them. Reduced-motion preferences remove the opacity transition.

Right-to-left scrolling permalink

Keep the DOM direction and DirectionProvider synchronized so horizontal wheel, track, thumb, and overflow-edge behavior use RTL coordinates.

Anatomy

  • Root owns measurement, overflow-edge state, the surface or plain variant, and optional autoHide styling.
  • Viewport is the native scroll container and receives the accessible name, keyboard focus, wheel, touch, and trackpad input.
  • Content wraps the layout whose dimensions create vertical, horizontal, or two-axis overflow.
  • Scrollbar renders one vertical or horizontal track and can remain mounted with keepMounted.
  • Thumb is the draggable position indicator inside its Scrollbar.
  • Corner fills the intersection when both scrollbars are present and overflowing.

API

PartProps and stateNotes
RootTRScrollAreaRootProps, variant, autoHide, overflowEdgeThreshold, render, refDefaults to the surface variant. plain removes the surface border and content padding.
ViewportTRScrollAreaViewportProps, TRScrollAreaViewportState, render, refNative scroll container. Base UI adds focusability only while an axis overflows.
ContentTRScrollAreaContentProps, TRScrollAreaContentState, render, refPreserve intrinsic width to enable horizontal overflow.
ScrollbarTRScrollAreaScrollbarProps, TRScrollAreaScrollbarState, orientation, keepMounted, render, reforientation defaults to vertical. Track wheel input scrolls the matching viewport axis.
ThumbTRScrollAreaThumbProps, TRScrollAreaThumbState, render, refDragging updates native viewport scroll position.
CornerTRScrollAreaCornerProps, TRScrollAreaCornerState, render, refMounts only while both axes overflow.

Overflow is reflected with data-overflow-x-start, data-overflow-x-end, data-overflow-y-start, and data-overflow-y-end; scrolling and track hover use data-scrolling and data-hovering. Customize the surface with --tr-scroll-area-background and --tr-scroll-area-color, the track with --tr-scroll-area-track-background, and the thumb with --tr-scroll-area-indicator-background. All parts preserve consumer classes, styles, native props, and React 19 refs.