Installation
npx logic2b@next add scroll-areaUsage
import { ScrollArea } from "@/components/ui/scroll-area"
<ScrollArea className="h-72 w-48 rounded-md border">
Jokester began sneaking into the castle in the middle of the night...
</ScrollArea>
Set the viewport size with className (height/width) — the content scrolls
inside it. For horizontal scrolling, render a ScrollBar with
orientation="horizontal" inside the ScrollArea.
Accessibility
The viewport is keyboard-focusable by default, so arrow, Page Up/Down, Home and End scrolling remain available even when its content has no interactive descendants. The visible focus ring identifies which scroll region owns those keys.
Examples
Horizontal
Long text
Live playground
Edit the component props and inspect the exact JSX before copying it. The preview loads only when this section enters the viewport.
<ScrollArea
className="h-48 w-full max-w-md rounded-lg border"
aria-label="Release notes"
>
<div
className="space-y-4 p-4"
>
<p
className="font-medium"
>Release 1.2</p>
<p
className="text-sm text-muted-foreground"
>Versioned registry manifests and integrity checks.</p>
<p
className="font-medium"
>Release 1.1</p>
<p
className="text-sm text-muted-foreground"
>Portable design tokens for web, iOS and Android.</p>
<p
className="font-medium"
>Release 1.0</p>
<p
className="text-sm text-muted-foreground"
>The first stable component registry.</p>
</div>
</ScrollArea>API reference
Generated from the public TypeScript exports in src/ui/scroll-area.tsx.
ScrollArea
ComponentProps: React.ComponentProps<typeof ScrollAreaPrimitive.Root>ScrollBar
ComponentProps: React.ComponentProps<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
orientation | "horizontal" | "vertical" | No | "vertical" | — |
Accessibility contract
Machine-readable behavior and consumer responsibilities for scroll-area.
- Support
- Primitive-managed
- Pattern
- scrollable region
- Radix Scroll Area
| Keys | Behavior |
|---|---|
| ArrowUp ArrowDown ArrowLeft ArrowRight PageUp PageDown | Scroll a focused scroll container with the keyboard. |
Built-in semantics
- Preserves the semantics of its children while providing custom visual scrollbars.
Consumer responsibilities
- Make the viewport focusable and label it only when the region itself needs keyboard scrolling or landmark semantics.