Scroll Area
Tags
---import { ScrollArea } from "@/components/starwind/scroll-area";import { Separator } from "@/components/starwind/separator";
const tags = Array.from({ length: 50 }).map((_, i, a) => `v1.2.0-beta.${a.length - i}`);---
<ScrollArea class="h-72 w-48 rounded-md border"> <div class="p-4"> <h4 class="mb-4 text-sm leading-none font-medium">Tags</h4> { tags.map((tag) => ( <div> <div class="text-sm">{tag}</div> <Separator class="my-2" /> </div> )) } </div></ScrollArea>import { ScrollArea } from "@/components/starwind/scroll-area";import { Separator } from "@/components/starwind/separator";
const tags = Array.from({ length: 50 }).map((_, i, a) => `v1.2.0-beta.${a.length - i}`);
export function Example() { return ( <> <ScrollArea className="h-72 w-48 rounded-md border"> <div className="p-4"> <h4 className="mb-4 text-sm leading-none font-medium">Tags</h4> { tags.map((tag) => ( <div key={tag}> <div className="text-sm">{tag}</div> <Separator className="my-2" /> </div> ))} </div> </ScrollArea> </> );}Installation
pnpx starwind@latest add scroll-areanpx starwind@latest add scroll-areayarn dlx starwind@latest add scroll-areaUsage
---import { ScrollArea, ScrollBar } from "@/components/starwind/scroll-area";---import { ScrollArea, ScrollBar } from "@/components/starwind/scroll-area";<ScrollArea class="h-[200px] w-[350px] rounded-md border p-4"> Your scrollable content here.</ScrollArea>import { ScrollArea } from "@/components/starwind/scroll-area";
export function Example() { return ( <> <ScrollArea className="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└── ScrollAreaCornerPass 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>import { ScrollArea, ScrollBar } from "@/components/starwind/scroll-area";
export function Example() { return ( <ScrollArea scrollbar={<ScrollBar orientation="horizontal" />}> Scrollable content </ScrollArea> );}Examples
Horizontal
Use ScrollBar with orientation="horizontal" for horizontal scrolling.
---import { ScrollArea, ScrollBar } from "@/components/starwind/scroll-area";---
<ScrollArea class="w-full max-w-xl rounded-md border" viewportClass="whitespace-nowrap"> <div class="flex w-max gap-2 p-4"> <span class="bg-muted text-muted-foreground rounded-md px-3 py-1.5 text-sm">#Astro</span> <span class="bg-muted text-muted-foreground rounded-md px-3 py-1.5 text-sm">#Tailwind</span> <span class="bg-muted text-muted-foreground rounded-md px-3 py-1.5 text-sm">#TypeScript</span> </div> <ScrollBar slot="scrollbar" orientation="horizontal" /></ScrollArea>import { ScrollArea, ScrollBar } from "@/components/starwind/scroll-area";
export function Example() { return ( <> <ScrollAreaclassName="w-full max-w-xl rounded-md border"viewportClassName="whitespace-nowrap"scrollbar={<ScrollBar orientation="horizontal" />}> <div className="flex w-max gap-2 p-4"> <span className="bg-muted text-muted-foreground rounded-md px-3 py-1.5 text-sm">#Astro</span> <span className="bg-muted text-muted-foreground rounded-md px-3 py-1.5 text-sm">#Tailwind</span> <span className="bg-muted text-muted-foreground rounded-md px-3 py-1.5 text-sm">#TypeScript</span> </div> </ScrollArea> </> );}RTL
You can enable RTL behavior by placing the component inside a container with dir="rtl".
العلامات
---import { ScrollArea } from "@/components/starwind/scroll-area";import { Separator } from "@/components/starwind/separator";---
const tags = Array.from({ length: 50 }).map((_, i, a) => `v1.2.0-beta.${a.length - i}`);
<div class="w-full max-w-md" dir="rtl"> <ScrollArea class="h-72 w-48 rounded-md border"> <div class="p-4 text-right"> <h4 class="mb-4 text-sm leading-none font-medium">العلامات</h4> { tags.map((tag) => ( <div> <div class="text-sm">{tag}</div> <Separator class="my-2" /> </div> )) } </div> </ScrollArea></div>import { ScrollArea } from "@/components/starwind/scroll-area";import { Separator } from "@/components/starwind/separator";
const tags = Array.from({ length: 50 }, (_, index) => `v1.2.0-beta.${50 - index}`);
export function Example() { return ( <div className="w-full max-w-md" dir="rtl"> <ScrollArea className="h-72 w-48 rounded-md border"> <div className="p-4 text-right"> <h4 className="mb-4 text-sm leading-none font-medium">العلامات</h4> {tags.map((tag) => ( <div key={tag}> <div className="text-sm">{tag}</div> <Separator className="my-2" /> </div> ))} </div> </ScrollArea> </div> );}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:
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.
Primitive API
Runtime API
- Scroll Area primitive
createScrollAreafrom@starwind-ui/runtime/scroll-area
Changelog
View version history v2.0.1 3 releases
v2.0.1
- Named the generated aggregate default export so React and Astro tooling can identify the installed component cleanly.
v2.0.0
- Rebuilt Scroll Area on Starwind Runtime with viewport, content, scrollbar, thumb, and corner anatomy.
- See the Scroll Area Primitive for the underlying unstyled anatomy and behavior API.
v1.0.0
- Initial Release with Starwind v2.0.0