Adopt the shared ScrollArea for app-wide scrolling

This commit is contained in:
Steven RYDELL
2026-07-29 07:20:43 +02:00
parent bd16e64e51
commit c15cb22be4
6 changed files with 45 additions and 26 deletions
+10 -3
View File
@@ -11,10 +11,17 @@ import { cn } from '@/lib/utils';
const ScrollArea = React.forwardRef<
React.ComponentRef<typeof ScrollAreaPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root>
>(({ className, children, ...props }, ref) => (
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root> & {
// Height caps (max-h-*) must be applied to the Viewport — the actual
// scroller — because a percentage height resolves to auto when the
// Root's height is content-driven, which would break scrolling.
viewportClassName?: string;
}
>(({ className, viewportClassName, children, ...props }, ref) => (
<ScrollAreaPrimitive.Root ref={ref} className={cn('relative overflow-hidden', className)} {...props}>
<ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]">{children}</ScrollAreaPrimitive.Viewport>
<ScrollAreaPrimitive.Viewport className={cn('h-full w-full rounded-[inherit]', viewportClassName)}>
{children}
</ScrollAreaPrimitive.Viewport>
<ScrollBar />
<ScrollAreaPrimitive.Corner />
</ScrollAreaPrimitive.Root>