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-areaFramework Availability
Astro Available React AvailableScroll Area is available for Astro and React.
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
Use the following composition to build a ScrollArea:
ScrollArea└── ScrollBarExamples
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>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>API Reference
Styled Component API
These props are added or materially changed by the installed Astro styled component. Standard HTML attributes remain available through the inherited interfaces noted below. 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
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