Repository navigation
Example of using ScrollArea within a sheet #8694
Replies: 2 comments
|
Yes, I used it. Shadcn ScrollArea requires a fixed height, so for dynamic layouts, we calculate the height based on available space. |
|
The trick is that the import {
Sheet, SheetContent, SheetHeader, SheetTitle, SheetFooter,
} from '@/components/ui/sheet'
import { ScrollArea } from '@/components/ui/scroll-area'
import { Button } from '@/components/ui/button'
export function ExampleSheet() {
return (
<Sheet>
{/* trigger etc. */}
<SheetContent className="flex flex-col">
<SheetHeader>
<SheetTitle>Title</SheetTitle>
</SheetHeader>
<ScrollArea className="min-h-0 flex-1">
<div className="space-y-4 pr-4">
{/* your long content here */}
</div>
</ScrollArea>
<SheetFooter>
<Button>Save</Button>
</SheetFooter>
</SheetContent>
</Sheet>
)
}The two details that make or break it:
If your And if you don't actually need Radix's custom scrollbar, a plain |
Uh oh!
There was an error while loading. Please reload this page.
Does anyone have a working example of using the ScrollArea component within a sheet?
All reactions