Scroll Area

A scrollable container with custom scrollbars and optional scroll shadow indicators.

Overview

The ScrollArea component provides a scrollable viewport with custom scrollbars and optional edge shadows. It does not paint its own surface by default; put it inside the surface that owns the frame.

Scrollbar styling is surface-aware. Tracks land two levels above the current surface and thumbs land four levels above the current surface. Scroll shadows default to the current surface color, so a scroll area inside Card automatically fades to the card surface.

Usage

import { Card } from "@tilt-legal/cubitt-components/card";
import {
  ScrollArea,
  ScrollAreaContent,
} from "@tilt-legal/cubitt-components/scroll-area";
<Card className="h-72 w-56">
  <ScrollArea className="h-full w-full">
    <ScrollAreaContent className="p-4">
      {/* Scrollable content */}
    </ScrollAreaContent>
  </ScrollArea>
</Card>

Examples

Basic

A vertical scroll area inside a card. The card owns the surface and the scroll content owns the padding.

Horizontal

Set orientation="horizontal" for horizontal overflow.

Both Directions

Set orientation="both" when content can overflow on both axes.

Scroll Shadows

Use scrollShadow to show edge gradients when more content is available.

Custom Shadow

Fine-tune shadow size, opacity, stop position, snap behavior, and color.

API Reference

ScrollArea

The root scrollable container component.

PropTypeDefaultDescription
orientation"vertical" | "horizontal" | "both""vertical"Direction of scrolling.
scrollShadow"vertical" | "horizontal" | "both" | "none" | ScrollShadowObjectConfig"none"Optional edge shadow configuration.
classNamestring—Additional classes for the viewport.

ScrollShadowConfig

PropertyTypeDefaultDescription
sizestring"40px"Size of the shadow gradient.
colorstringCurrent surfaceCSS color used for the gradient.
stopPercentnumber0Percentage where the solid color ends and fading begins.
stopOpacitynumber100Opacity of the intermediate color stop before fading to transparent.
snapbooleanfalseWhen true, the shadow appears at full size instead of growing gradually.

ScrollShadowObjectConfig

The object configuration supports axis shortcuts or individual sides. Do not mix an axis shortcut with that axis' side-specific keys.

PropertyTypeDescription
verticalboolean | ScrollShadowConfigShortcut for top and bottom shadows.
horizontalboolean | ScrollShadowConfigShortcut for left and right shadows.
topboolean | ScrollShadowConfigTop shadow. Cannot be used with vertical.
bottomboolean | ScrollShadowConfigBottom shadow. Cannot be used with vertical.
leftboolean | ScrollShadowConfigLeft shadow. Cannot be used with horizontal.
rightboolean | ScrollShadowConfigRight shadow. Cannot be used with horizontal.

ScrollAreaContent

Container for the scrollable content.

PropTypeDefaultDescription
classNamestring—Additional classes for the content container.

ScrollBar

Custom scrollbar component used internally by ScrollArea.

PropTypeDefaultDescription
orientation"vertical" | "horizontal""vertical"Direction of the scrollbar.
classNamestring—Additional classes for the track.

CSS Custom Properties

Scrollbar inset variables are orientation-specific. Vertical scrollbars read the top and bottom variables; horizontal scrollbars read the left and right variables.

VariableDefaultDescription
--scrollbar-inset-top1remTop inset used by vertical scrollbar tracks.
--scrollbar-inset-bottom1remBottom inset used by vertical scrollbar tracks.
--scrollbar-inset-left0remLeft inset used by horizontal scrollbar tracks.
--scrollbar-inset-right0remRight inset used by horizontal scrollbar tracks.

On this page