Menu

Change language

GitHub repo

Scroll Area

scroll-areaui

Custom scrollbar that always renders the same way across OSes (no flashing native scrollbars on Windows). Use for sidebars, dropdown content, and any overflow region you want to feel consistent.

Installation

$npx shadcn-svelte@latest add https://uipkge.dev/r/svelte/scroll-area.json
Manifest:https://uipkge.dev/r/svelte/scroll-area.jsonInstalls to:src/lib/components/ui/scroll-area/

Examples

Loading interactive previews…

Props

NameType / ValuesDefaultRequired
childrenSnippet—optional
refHTMLDivElement | null—optional

Used by

Files installed (3)

  • src/lib/components/ui/scroll-area/ScrollArea.svelte1 kB
    <script lang="ts" module>
      import type { Snippet } from 'svelte'
      import type { HTMLAttributes } from 'svelte/elements'
    
      export interface ScrollAreaProps extends HTMLAttributes<HTMLDivElement> {
        children?: Snippet
        ref?: HTMLDivElement | null
      }
    </script>
    
    <script lang="ts">
      import { cn } from '$lib/utils'
      import ScrollBar from './ScrollBar.svelte'
    
      let { class: className, children, ref = $bindable(null), ...restProps }: ScrollAreaProps = $props()
    </script>
    
    <div bind:this={ref} data-uipkge data-slot="scroll-area" class={cn('relative', className)} {...restProps}>
      <div
        data-uipkge
        data-slot="scroll-area-viewport"
        tabindex="0"
        class="focus-visible:ring-ring/50 size-full overflow-auto rounded-[inherit] transition-[color,box-shadow] outline-none [scrollbar-width:none] focus-visible:ring-[3px] focus-visible:outline-1 [&::-webkit-scrollbar]:hidden"
      >
        {@render children?.()}
      </div>
      <ScrollBar />
      <div data-uipkge data-slot="scroll-area-corner" class="absolute right-0 bottom-0 size-2.5"></div>
    </div>
    
  • src/lib/components/ui/scroll-area/ScrollBar.svelte6.6 kB
  • src/lib/components/ui/scroll-area/index.ts0.2 kB

Raw manifest:https://uipkge.dev/r/svelte/scroll-area.json