shadcn.io is not affiliated with official shadcn/ui
Scroll Area examples · Advanced
Both Orientations Scroll Area for React
A scroll area that scrolls both ways, for a table with more columns and rows than fit.
Wide tables with many columns make people pan sideways, lose context, then scroll down and lose their place again. This example puts a six-column, twenty-row table in a 400px Scroll Area that scrolls on both axes. The inner wrapper uses w-max, so the columns never wrap and the content sets the width. Use it for data tables, spreadsheets, and admin panels whose content is both wider and taller than its frame.
Preview
Installation
FAQ
Why does this table scroll both ways?
ScrollArea is h-[400px] and max-w-md, and the table sits in a div with w-max. The fixed height scrolls the twenty rows. w-max lets the six columns run wider than the frame.
Which bar does this file add?
ScrollBar with orientation set to horizontal. The root already renders the vertical bar. Both are inside the same ScrollArea.
What are the columns?
Name, Email, Role, Department, Location, and Status. Each th and the cells use px-4 py-2 and text-start. Body cells that are secondary, such as the email, add text-sm text-muted-foreground.
How many people are in the table?
Twenty, from Array.from. Role cycles Admin, Editor, and Viewer. Department cycles Engineering, Design, Marketing, and Sales. Location is San Francisco or New York. Status is Active or Inactive.
Related
- Horizontal ScrollArea Scroll AreaA horizontal scroll area for an image
- Basic ScrollArea Scroll AreaA basic vertical scroll area for long
- Basic TableA bordered table of users with their
- Basic Data Table with CheckboxesA table of products with a checkbox on
- With Resizable Panels Scroll AreaTwo resizable panels, each with its own
- Dynamic Content Scroll AreaA scroll area whose list grows with a