Scroll Area
A custom scrollable area with native scrolling but custom styled scrollbars.
Installation
npm i @radix-ui/react-scroll-areaUsage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { ScrollArea } from "@/components/ui/scroll-area"
export function ScrollAreaDemo() {
return (
<ScrollArea className="h-[200px] w-[350px] rounded-md border p-4">
<div className="space-y-4">
<h4 className="text-sm font-medium leading-none">ScrollArea Demo</h4>
<p className="text-sm">
This is a scrollable area with custom scrollbars. It uses Radix UI's ScrollArea
primitive and is styled with Tailwind CSS.
</p>
<p className="text-sm">
Long content goes here. When it overflows the container, the scrollbar will appear.
The scrollbar is styled to match the design system and provides a consistent
look across different browsers.
</p>
<p className="text-sm">
You can scroll using the scrollbar, mouse wheel, touch gestures, or keyboard
navigation. The scrollbar only appears when needed and can be styled to fit
your design needs.
</p>
<p className="text-sm">
Additional content to make sure we have enough to scroll. Lorem ipsum dolor
sit amet, consectetur adipiscing elit. Cras nec justo vel nisi consectetur
tincidunt ac in turpis.
</p>
</div>
</ScrollArea>
)
}Examples
Horizontal Scroll
Scrollbar Visibility
Default (visible on hover)
Always visible
Visible when scrolling
Props
| Component | Props | Description |
|---|---|---|
| ScrollArea | ScrollAreaPrimitive.ScrollAreaProps type?: "auto" | "always" | "scroll" | "hover" scrollHideDelay?: number | The root component for the scroll area. |
| ScrollBar | ScrollAreaPrimitive.ScrollAreaScrollbarProps orientation?: "vertical" | "horizontal" | The scrollbar component that appears when content overflows. |