Display
Scroll area
A box with its own scrolling and a thin pill scrollbar. Use it for long lists inside a fixed-height card or for a row of cards that scrolls sideways.
import { ScrollArea } from '@statix/ui/scroll-area';Examples
Vertical
Give the root a height. The scrollbar thumb is ink at 20% and darkens on hover.
Backups of yoga-berger.de
- 30 October, 03:10
- 29 October, 03:10
- 28 October, 03:10
- 27 October, 03:10
- 26 October, 03:10
- 25 October, 03:10
- 24 October, 03:10
- 23 October, 03:10
- 22 October, 03:10
- 21 October, 03:10
- 20 October, 03:10
- 19 October, 03:10
- 18 October, 03:10
- 17 October, 03:10
- 16 October, 03:10
- 15 October, 03:10
- 14 October, 03:10
- 13 October, 03:10
- 12 October, 03:10
- 11 October, 03:10
- 10 October, 03:10
- 9 October, 03:10
- 8 October, 03:10
- 7 October, 03:10
- 6 October, 03:10
- 5 October, 03:10
- 4 October, 03:10
- 3 October, 03:10
- 2 October, 03:10
- 1 October, 03:10
<script lang="ts">
import { ScrollArea } from '@statix/ui/scroll-area';
const backups = Array.from({ length: 30 }, (_, i) => `${30 - i} October, 03:10`);
</script>
<ScrollArea class="h-72 w-full max-w-xs rounded-lg bg-card" aria-label="Backups of yoga-berger.de">
<div class="px-4 py-2">
<p class="py-2 text-label text-muted-foreground">Backups of yoga-berger.de</p>
<ul class="divide-y divide-border">
{#each backups as backup (backup)}
<li class="py-2.5 text-body text-ink">{backup}</li>
{/each}
</ul>
</div>
</ScrollArea>Horizontal
orientation="horizontal" for a row of cards. Leave padding below the row for the scrollbar.
yoga-berger.de
WordPress Hosting
berger-physio.de
WordPress Hosting
laufgruppe-altona.de
Static site
atelier-nord.de
Online shop
hafenblick-hamburg.de
WordPress Hosting
<script lang="ts">
import { ScrollArea } from '@statix/ui/scroll-area';
const websites = [
{ domain: 'yoga-berger.de', plan: 'WordPress Hosting' },
{ domain: 'berger-physio.de', plan: 'WordPress Hosting' },
{ domain: 'laufgruppe-altona.de', plan: 'Static site' },
{ domain: 'atelier-nord.de', plan: 'Online shop' },
{ domain: 'hafenblick-hamburg.de', plan: 'WordPress Hosting' }
];
</script>
<ScrollArea orientation="horizontal" class="w-full max-w-xl" aria-label="Your websites">
<div class="flex gap-4 pb-4">
{#each websites as site (site.domain)}
<div class="w-56 shrink-0 rounded-lg bg-card p-5">
<p class="text-subtitle text-ink">{site.domain}</p>
<p class="mt-1 text-small text-muted-foreground">{site.plan}</p>
</div>
{/each}
</div>
</ScrollArea>Guidelines
Do
- Set a fixed height or width on the root, otherwise nothing scrolls.
- Show part of the next item so the customer sees there is more.
Don't
- Do not nest scroll areas.
- Do not wrap a whole page in it. The browser scrolls pages.
Accessibility
- The viewport is focusable (tabindex 0) so keyboard users can scroll it with the arrow keys. Set viewportTabindex={-1} when the content already has focusable items.
- Give the root an aria-label when the list has no visible heading.
- Mouse wheel, touch and keyboard scrolling use the native scroll, so they behave as usual.
API reference
ScrollArea
renders<div> and accepts its attributes| Prop | Type | Default |
|---|---|---|
orientation | 'vertical' | 'horizontal' | 'both' Which scrollbars to render. | 'vertical' |
type | 'hover' | 'scroll' | 'auto' | 'always' When the scrollbars show. | 'hover' |
viewportTabindex | number Statix addition. Tab index of the viewport. | 0 |
scrollbarXClasses | string Classes for the horizontal scrollbar. | – |
scrollbarYClasses | string Classes for the vertical scrollbar. | – |
ref bind | HTMLDivElement | null The root element. | – |
viewportRef bind | HTMLElement | null The scrolling viewport, for reading or setting scrollTop. | – |
class | ClassValue Merged with the root classes. | – |
| Data attribute | Meaning |
|---|---|
data-slot="scroll-area" | The root. |
data-slot="scroll-area-viewport" | The scrolling element. |
data-slot="scroll-area-thumb" | The scrollbar thumb. |
ScrollAreaScrollbar
renders<div> and accepts its attributesRendered for you by ScrollArea. Use it directly only when you build your own root.
| Prop | Type | Default |
|---|---|---|
orientation | 'vertical' | 'horizontal' Direction. | 'vertical' |
class | ClassValue Merged with the scrollbar classes. | – |
| Data attribute | Meaning |
|---|---|
data-slot="scroll-area-scrollbar" | Always present. |
data-orientation | "vertical" or "horizontal". |