ScrollArea
LayoutA scrollable box with slim scrollbars that match the theme: give it a height (or width) and orientation (vertical, horizontal, both). It scrolls with the wheel, touch and keyboard like any scrolling box. ScrollArea.Scrollbar is there for custom layouts.
import { ScrollArea } from '@limerdev/zest'; Examples
A list
A fixed-height list with a slim scrollbar.
Projects
Project 1
Project 2
Project 3
Project 4
Project 5
Project 6
Project 7
Project 8
Project 9
Project 10
Project 11
Project 12
Project 13
Project 14
Project 15
Project 16
Project 17
Project 18
Project 19
Project 20
Project 21
Project 22
Project 23
Project 24
Project 25
Project 26
Project 27
Project 28
Project 29
Project 30
<script lang="ts">
import { ScrollArea, Separator } from '@limerdev/zest';
const projects: string[] = Array.from({ length: 30 }, (_, index) => `Project ${index + 1}`);
</script>
<ScrollArea.Root class="h-60 w-56 rounded-box border-(length:--border) border-border bg-base-100">
<div class="p-4">
<p class="mb-3 text-sm font-medium">Projects</p>
{#each projects as project, index (project)}
{#if index > 0}
<Separator class="my-2" />
{/if}
<p class="text-sm">{project}</p>
{/each}
</div>
</ScrollArea.Root> Horizontal
orientation="horizontal" scrolls a row sideways.
<script lang="ts">
import { ScrollArea } from '@limerdev/zest';
const weeks: number[] = Array.from({ length: 16 }, (_, index) => index + 40);
</script>
<ScrollArea.Root
orientation="horizontal"
class="w-full max-w-md rounded-box border-(length:--border) border-border bg-base-100"
>
<div class="flex gap-3 p-4">
{#each weeks as week (week)}
<div class="grid h-20 w-28 shrink-0 place-content-center rounded-field bg-base-200 text-sm">
Week {week}
</div>
{/each}
</div>
</ScrollArea.Root> Props
Every part also takes class (merged over its defaults), ref (bindable: the element), children, and child (a snippet that
renders your own element, with props to spread on it).
ScrollArea.Root
| Prop | Type | Default | Description |
|---|---|---|---|
| dir | "ltr" | "rtl" | – | The reading direction of the application. |
| orientation | "both" | "horizontal" | "vertical" | 'vertical' | Which scrollbars to draw: vertical, horizontal or both. |
| scrollbarXClasses | string | '' | Classes for the horizontal scrollbar. |
| scrollbarYClasses | string | '' | Classes for the vertical scrollbar. |
| scrollHideDelay | number | 600 | The amount of time in milliseconds to delay before hiding the scrollbars after leaving the scroll area or stopping scrolling. |
| type | "auto" | "always" | "hover" | "scroll" | "hover" | The type of scroll area to render. |
| viewportRef bindable | HTMLElement | null | null | The scrolling viewport element. Bindable. |
ScrollArea.Scrollbar
| Prop | Type | Default | Description |
|---|---|---|---|
| forceMount | boolean | – | Whether to forcefully mount the component. Useful when working with external animation/transition libraries. |
| orientation required | "horizontal" | "vertical" | 'vertical' |