Scroll Area
A region that scrolls its content with thin native scrollbars.
Installation
npx shadcn@latest add @oakoss/scroll-areaUsage
import { ScrollArea } from '#/components/ui/layout/scroll-area';
<ScrollArea aria-label="Tags" className="h-72">
…
</ScrollArea>;Examples
Horizontal
orientation="horizontal" scrolls sideways only; vertical scrolls up and
down only, and the default, both, scrolls either way. Content that overflows
the other way is clipped.
Accessibility
The scrollbars are the browser's own, so touch, wheel, keyboard and assistive technology scroll it as they would any page. While its content overflows, the area is focusable, so keyboard users can tab to it and scroll with the arrow keys, and up and down with Page Up, Page Down, Home and End; content that fits adds no tab stop. Its focus ring sits inside its edge, where a clipping parent can't hide it. React Aria adds no keys.
Give it a name (aria-label or aria-labelledby), so screen readers
announce what the focused area holds; a named area is a region while it
scrolls. The thumb is the input
border color, which meets 3:1 against the page, and forced colors repaint
the scrollbar and the focus ring in system colors.
API
ScrollArea
A div that scrolls its content. Size it with className (h-72); the
scrollbars appear only when the content overflows.
Props
Prop
Type
Also accepts div props.
Data attributes
| Attribute | Present when |
|---|---|
data-slot | Always: scroll-area |
data-orientation | Always: both, horizontal or vertical |