Skip to main content

Starwind UI v3.0 is now available! Migration guide

Scroll Area

Installation

Usage

---
import { ScrollArea, ScrollBar } from "@/components/starwind/scroll-area";
---
<ScrollArea class="h-[200px] w-[350px] rounded-md border p-4">
Your scrollable content here.
</ScrollArea>

Composition

ScrollArea provides the viewport, content wrapper, vertical scrollbar, thumb, and corner. The rendered structure is:

ScrollArea
├── ScrollAreaViewport
│ └── ScrollAreaContent
├── ScrollBar
│ └── ScrollAreaThumb
└── ScrollAreaCorner

Pass a custom scrollbar through the framework-specific API:

---
import { ScrollArea, ScrollBar } from "@/components/starwind/scroll-area";
---
<ScrollArea>
Scrollable content
<ScrollBar slot="scrollbar" orientation="horizontal" />
</ScrollArea>

Examples

Horizontal

Use ScrollBar with orientation="horizontal" for horizontal scrolling.

RTL

You can enable RTL behavior by placing the component inside a container with dir="rtl".

API Reference

Styled Component API

These props are added or materially changed by the installed styled component. Standard HTML attributes remain available through the inherited interfaces noted below. Expand a prop to see named type definitions and framework-specific imports. Follow the Primitive and Runtime links for lower-level behavior props.

Scroll Area

Inherits div attributes.

Contains the following additional props:

Prop Type Default Toggle details
autoViewport boolean true
Description
Automatically renders the viewport and content wrappers. Set false to compose those parts yourself.
Classification
Wrapper prop
overflowEdgeThreshold number —
Description
Sets the distance from an edge that counts as overflow.
Classification
Primitive override
Primitive prop
scroll-area.Root.overflowEdgeThreshold
viewportClass string —
Description
Adds classes to the generated viewport element.
Classification
Wrapper prop

Primitive And Runtime API

Use these references when you need the lower-level behavior APIs behind Scroll Area.

Runtime API

Scroll Area primitive
createScrollArea from @starwind-ui/runtime/scroll-area

Changelog

View version history v2.1.0 4 releases

v2.1.0

  • Added autoViewport across frameworks. It defaults to true; set it to false to compose the viewport and content parts yourself.

v2.0.1

  • The default export in index.ts now has a name, ScrollAreaParts, so framework tools show a clear name.

v2.0.0

  • Scroll Area now gets its behavior from Starwind Runtime. It has viewport, content, scrollbar, thumb, and corner parts.
  • See the Scroll Area Primitive for the unstyled parts and the behavior API.

v1.0.0

  • Initial Release with Starwind v2.0.0