Scroll Area
- Svelte 5 runes migration
- Designing the studio preset
- Tailwind v4 token setup
- Pagination active state
- Figma plugin ideas
- Vercel deploy hook
- Refactor command palette
- Hover card focus order
- Toast queue logic
- Color picker math
- Button loading states
- Dialog scroll behavior
Installation
npx @mielui/svelte add scroll-areayarn dlx @mielui/svelte add scroll-areabunx @mielui/svelte add scroll-areaUsage
Put the scrolling content in children and give the area a height or maximum height with class; without one it grows to fit and never scrolls. class styles the outer shell; other attributes and bind:element go to the scroll viewport.
<script lang="ts">
import { ScrollArea } from '@mielui/svelte/components/scroll-area';
</script>
<ScrollArea class="h-48 w-64">
<div>Your content here</div>
</ScrollArea>The viewport is not a tab stop by itself. When its content has no focusable controls, add tabindex={0}, role="region", and an aria-label so keyboard users can scroll it.
A vertical scroll area fades its overflowing edges into the surface behind it and blurs the content passing under them. The cues update as content is inserted, removed, or resized. Pass showCues={false} to drop them, or blur={false} to keep the fade without a backdrop filter. The scrollbar thumb stays hidden until the area is hovered, focused, or scrolled.
While its content overflows, a scroll area keeps the wheel to itself, so reaching the end does not scroll the page behind it. When everything fits, scrolling passes through to the page.
Examples
Grouped list
A chat history with date labels and a selected row scrolls inside a fixed height.
Horizontal
Both directions
Edge cue blur
blur={false} keeps the fade without a backdrop filter, which is worth doing over long or animated content.
API reference
ScrollArea
Provides a scrollable content area.
orientation"vertical" | "horizontal" | "both"Scroll direction.
Default
'vertical'showCuesbooleanFades an edge that has more content.
Default
trueblurbooleanBlurs content as it passes under a faded edge.
Default
truechildrenSnippet<[]>Content rendered inside.
elementBindableHTMLDivElementBindable reference to the DOM element.
classstringClasses added to the element.
pnpm dlx @mielui/svelte add scroll-area