Base · Data display
Scroll area
A fixed-size region whose content scrolls behind a thin custom scrollbar.
Props
import { ScrollArea } from "@/components/ui/scroll-area"
<ScrollArea className="h-56 w-64 rounded-lg border">
<div className="p-3">
<h4 className="mb-3 text-sm font-medium">Recent scans</h4>
{scans.map((scan) => (
<div key={scan.id} className="text-sm">
Pallet {scan.number}
</div>
))}
</div>
</ScrollArea>Overview
Scroll area wraps content that is taller than its container and replaces the browser scrollbar with a slim themed one that looks the same on every operating system. Scrolling itself stays native, so wheel, touch and keyboard all behave as usual.
When to use
- For a bounded list inside a card, popover or sidebar, such as recent scans or a long menu.
- When the default scrollbar would take layout space or clash with the surface it sits on.
- For a horizontally scrolling strip, by adding a ScrollBar with orientation="horizontal".
When not to use
- For the page itself: let the document scroll with the browser scrollbar.
- For very long lists of hundreds of rows: add virtualization, or paginate.
- To hide overflow that people do not need: truncate the content instead.
- For a wide table: Table already scrolls horizontally on its own.
Anatomy
Root
The sized container. Set its height (and width) with a class; it takes any corner radius.
Viewport
The element that actually scrolls. Focusable, with a focus ring.
Scrollbar
A 10px track on the right edge. Add ScrollBar with orientation="horizontal" for the bottom edge.
Thumb
The draggable pill in the border color.
Props
The contract every language implements. Names follow each language’s conventions (camelCase in React, snake_case in Rust).
| Prop | Type | Default | Description |
|---|---|---|---|
| title | string | Recent scans | Heading above the list in the demo. Not a ScrollArea prop. |
| itemLabel | string | Pallet | Prefix of each row in the demo. Not a ScrollArea prop. |
| className | string | – | Sets the size of the region, such as h-56 w-64. Without a height the area grows with its content and never scrolls. |
| children | node | – | The content to scroll. |
States
- Rest
- The thumb is visible whenever the content overflows.
- Scrolling
- The thumb moves with the content and can be dragged.
- Focus-visible
- 3px focus ring on the viewport when reached with the keyboard.
- No overflow
- The scrollbar is not shown when the content fits.
Accessibility
| Keys | Action |
|---|---|
| Tab | Moves focus to the viewport when it overflows, then on to focusable content inside it. |
| Arrow Up/Arrow Down | Scrolls the focused viewport by a small amount. |
| Page Up/Page Down/Space | Scrolls by one viewport height. |
| Home/End | Scrolls to the top or bottom. |
- Scrolling is native overflow, so screen reader and touch gestures work without extra handling.
- The custom scrollbar is a pointer affordance only and is hidden from assistive technology.
- If the region has a heading, give the root role="region" and aria-labelledby so it is announced as a landmark.
Design tokens
Change any of these in Foundations and this component follows, in every language.
Platform notes
- HTML / JS
- Planned
- Not built in HTML / JS yet.
- React
- Stable
- Matches the contract with no platform differences.
- React Native
- Draft
- A ScrollView in a clipped frame: the platform draws its own overlay indicator, so there is no ScrollBar part. Size the frame with style.
- Swift (SwiftUI)
- Planned
- Not built in Swift yet.
- Godot
- Planned
- Not built in Godot yet.
- Vue
- Draft
- Usage snippet only; same props and behavior as the React component.
- Svelte
- Draft
- Usage snippet only (Svelte 5); same props and behavior as the React component.
- Solid
- Draft
- Usage snippet only; same props and behavior as the React component.