# All files / src/components/ui scroll-area.tsx

0% Statements 0/7
0% Branches 0/5
100% Functions 0/0
0% Lines 0/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49

     "use client"

    import * as React from "react"
    import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area"

    import { cn } from "@/lib/utils"

    const ScrollArea = React.forwardRef<
      React.ElementRef<typeof ScrollAreaPrimitive.Root>,
      React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root>
    >(({ className, 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>
        <ScrollBar />
        <ScrollAreaPrimitive.Corner />
      </ScrollAreaPrimitive.Root>
    ))
    ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName

    const ScrollBar = React.forwardRef<
      React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,
      React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>
    >(({ className, orientation = "vertical", ...props }, ref) => (
      <ScrollAreaPrimitive.ScrollAreaScrollbar
        ref={ref}
        orientation={orientation}
        className={cn(
          "flex touch-none select-none transition-colors",
          orientation === "vertical" &&
            "h-full w-2.5 border-l border-l-transparent p-[1px]",
          orientation === "horizontal" &&
            "h-2.5 flex-col border-t border-t-transparent p-[1px]",
          className
        )}
        {...props}
      >
        <ScrollAreaPrimitive.ScrollAreaThumb className="relative flex-1 rounded-full bg-border" />
      </ScrollAreaPrimitive.ScrollAreaScrollbar>
    ))
    ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName

    export { ScrollArea, ScrollBar }