Scroll Area
Augments native scroll functionality for custom, cross-browser styling.
Installation
pnpm add @heyramzi/ui bits-uiUsage
import { ScrollArea } from "@heyramzi/ui/shadcn/scroll-area";<ScrollArea class="h-72 w-48 rounded-md border">
{#each tags as tag (tag)}
<div>{tag}</div>
{/each}
</ScrollArea>Keyboard and accessibility
- The content scrolls natively, so the wheel, touch and a focused element inside all scroll it.
- The viewport sets no tabindex. Chrome and Firefox still let Tab reach it when nothing inside can take focus, and then the arrow keys scroll it. Safari doesn't.
API reference
ScrollArea.Root
orientation"vertical" | "horizontal" | "both"- Default
"vertical" scrollbarXClassesstring | undefined- Default
"" scrollbarYClassesstring | undefined- Default
"" viewportRefbindableHTMLElement | null- Default
null refbindableHTMLElement | null- Default
null classstringchildrenSnippet...rest- Every prop of
ScrollArea.Rootfrombits-uiexceptchild
| Prop | Type | Default |
|---|---|---|
orientation | "vertical" | "horizontal" | "both" | "vertical" |
scrollbarXClasses | string | undefined | "" |
scrollbarYClasses | string | undefined | "" |
viewportRef bindable | HTMLElement | null | null |
ref bindable | HTMLElement | null | null |
class | string | |
children | Snippet | |
...rest | Every prop of ScrollArea.Root from bits-ui except child | |
ScrollArea.Scrollbar
refbindableHTMLElement | null- Default
null classstringorientationstring- Default
"vertical" childrenSnippet...rest- Every prop of
ScrollArea.Scrollbarfrombits-uiexceptchild
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLElement | null | null |
class | string | |
orientation | string | "vertical" |
children | Snippet | |
...rest | Every prop of ScrollArea.Scrollbar from bits-ui except child | |