shadcn.io is not affiliated with official shadcn/ui
Scroll Area examples · Advanced
With Resizable Panels Scroll Area for React
Two resizable panels, each with its own scroll area, for a split-pane file browser.
IDE-style layouts need resizable panes: people adjust the sidebar's width without losing their place in the file list or the preview. This example splits a Resizable into a Files panel and a Preview panel, each a 400px column with a header and a Scroll Area that fills the rest with min-h-0 flex-1. A ResizableResizeTrigger with withHandle between them shows a grip, and each panel keeps at least 30% of the width. Use it for code editors, file explorers, and mail clients.
Preview
Installation
FAQ
How are the two panels sized?
Files and Preview sit side by side. Each one starts at half the group.
Each ResizablePanel has defaultSize "50%" and minSize "30%". orientation is horizontal on Resizable, so those values are widths. For minSize, a number is pixels and a percentage is a string.
What does withHandle do?
ResizableResizeTrigger sets withHandle, which shows the grip between Files and Preview. The trigger's accessible name is Resize. Focus it and the arrow keys change the sizes. Home and End jump toward the ends of the range.
Why do the scroll areas use min-h-0 and flex-1?
Each panel's body is a h-[400px] column, flex flex-col. The header is a border-b row. ScrollArea has min-h-0 flex-1, so it takes the height left under that header and scrolls inside it.
What is in the Files list?
Thirty buttons, type button, labeled file-1.tsx through file-30.tsx, each with "Updated N days ago" in text-xs text-muted-foreground. The button is w-full with px-3 py-2 and hover:bg-accent. The list wrapper is gap-1 p-2.
Related
- Both Orientations Scroll AreaA scroll area that scrolls both ways, for
- Fixed Height ScrollArea Scroll AreaA notification list in a 200px scroll
- Basic ScrollArea Scroll AreaA basic vertical scroll area for long
- Dynamic Content Scroll AreaA scroll area whose list grows with a
- Chat Messages Scroll AreaA chat message list in a fixed-height
- Scrollable Tags Scroll AreaA row of technology badges in a