2024-04-14 14:53:57 +02:00
|
|
|
<script lang="ts">
|
2025-06-08 16:32:41 +02:00
|
|
|
import { ScrollArea as ScrollAreaPrimitive, type WithoutChild } from "bits-ui";
|
|
|
|
|
import { Scrollbar } from "./index.js";
|
|
|
|
|
import { cn } from "$lib/utils.js";
|
2024-04-14 14:53:57 +02:00
|
|
|
|
2025-06-08 16:32:41 +02:00
|
|
|
let {
|
|
|
|
|
ref = $bindable(null),
|
|
|
|
|
class: className,
|
|
|
|
|
orientation = "vertical",
|
|
|
|
|
scrollbarXClasses = "",
|
|
|
|
|
scrollbarYClasses = "",
|
|
|
|
|
children,
|
|
|
|
|
...restProps
|
|
|
|
|
}: WithoutChild<ScrollAreaPrimitive.RootProps> & {
|
|
|
|
|
orientation?: "vertical" | "horizontal" | "both" | undefined;
|
|
|
|
|
scrollbarXClasses?: string | undefined;
|
|
|
|
|
scrollbarYClasses?: string | undefined;
|
|
|
|
|
} = $props();
|
2024-04-14 14:53:57 +02:00
|
|
|
</script>
|
|
|
|
|
|
2025-06-08 16:32:41 +02:00
|
|
|
<ScrollAreaPrimitive.Root bind:ref {...restProps} class={cn("relative overflow-hidden", className)}>
|
|
|
|
|
<ScrollAreaPrimitive.Viewport class="h-full w-full rounded-[inherit]">
|
|
|
|
|
{@render children?.()}
|
2024-04-14 14:53:57 +02:00
|
|
|
</ScrollAreaPrimitive.Viewport>
|
2025-06-08 16:32:41 +02:00
|
|
|
{#if orientation === "vertical" || orientation === "both"}
|
2024-04-14 14:53:57 +02:00
|
|
|
<Scrollbar orientation="vertical" class={scrollbarYClasses} />
|
|
|
|
|
{/if}
|
2025-06-08 16:32:41 +02:00
|
|
|
{#if orientation === "horizontal" || orientation === "both"}
|
2024-04-14 14:53:57 +02:00
|
|
|
<Scrollbar orientation="horizontal" class={scrollbarXClasses} />
|
|
|
|
|
{/if}
|
|
|
|
|
<ScrollAreaPrimitive.Corner />
|
|
|
|
|
</ScrollAreaPrimitive.Root>
|