Files
gpx.studio/website/src/lib/components/ui/scroll-area/scroll-area.svelte

41 lines
1.4 KiB
Svelte
Raw Normal View History

2024-04-14 14:53:57 +02:00
<script lang="ts">
2025-06-21 21:07:36 +02:00
import { ScrollArea as ScrollAreaPrimitive } from 'bits-ui';
import { Scrollbar } from './index.js';
import { cn, type WithoutChild } from '$lib/utils.js';
2024-04-14 14:53:57 +02:00
2025-06-21 21:07:36 +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-21 21:07:36 +02:00
<ScrollAreaPrimitive.Root
bind:ref
data-slot="scroll-area"
class={cn('relative overflow-hidden', className)}
{...restProps}
>
<ScrollAreaPrimitive.Viewport
data-slot="scroll-area-viewport"
class="ring-ring/10 dark:ring-ring/20 dark:outline-ring/40 outline-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] focus-visible:outline-1 focus-visible:ring-4"
>
{@render children?.()}
</ScrollAreaPrimitive.Viewport>
{#if orientation === 'vertical' || orientation === 'both'}
<Scrollbar orientation="vertical" class={scrollbarYClasses} />
{/if}
{#if orientation === 'horizontal' || orientation === 'both'}
<Scrollbar orientation="horizontal" class={scrollbarXClasses} />
{/if}
<ScrollAreaPrimitive.Corner />
2024-04-14 14:53:57 +02:00
</ScrollAreaPrimitive.Root>