shadcn.io is not affiliated with official shadcn/ui
Scroll Area examples · Standard
Basic ScrollArea Scroll Area for React
A basic vertical scroll area for long text, such as terms of service.
Long legal text and documentation can make a page endless. This example puts Terms of Service in a Scroll Area with a fixed height (h-72), so the text scrolls inside its border once it overflows and the rest of the page stays put. The scrollbar follows your theme in light and dark mode. Use it for terms, privacy policies, changelogs, and help text that should not dominate the layout.
Preview
Installation
FAQ
Why does this terms list scroll?
ScrollArea has h-72, so the box is shorter than the seven paragraphs inside it. A scroll area scrolls when its box is smaller than the content. The width is w-full max-w-md.
Where is the padding?
On the inner div, as p-4, so it scrolls with the terms. The heading is an h4 with mb-4, and the paragraphs are flex flex-col gap-4 with text-sm text-muted-foreground.
What draws the frame?
rounded-md border on ScrollArea. This file adds no background class. The heading text is "Terms of Service".
How do I change the scrollbar?
The frame classes live on ScrollArea. The thumb lives in the scroll-area file under components/ui.
The thumb is data-slot scroll-area-thumb. ScrollBar is the part around it. This file uses the vertical bar the root already renders.
Related
- Fixed Height ScrollArea Scroll AreaA notification list in a 200px scroll
- Horizontal ScrollArea Scroll AreaA horizontal scroll area for an image
- Both Orientations Scroll AreaA scroll area that scrolls both ways, for
- Dynamic Content Scroll AreaA scroll area whose list grows with a
- Standard DialogA share dialog with a read-only link, a
- Simple CollapsibleA ghost Toggle button with a chevron that