Primitives Layout and display
Scroll area
A scrolling region with thin styled scrollbars and edge shadows that a keyboard user can reach, for content taller or wider than its box.
Markdown version of this page, for assistants (Markdown for AI)
On this page
2.4
Offline sync for notes; conflicts are shown side by side.
2.3
Shared folders with read-only members.
2.2
Search across attachments, including scanned pages.
2.1
Keyboard shortcuts for every command in the editor.
2.0
A new editor with tables, checklists and code blocks.
1.9
Exports to Markdown and HTML.
1.8
Reminders on notes, with a daily digest.
Code
<script lang="ts">
import '@svelte-lean/styles/scroll-area.css';
</script>
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
<div
role="region"
aria-label="Release notes"
tabindex="0"
data-slean="scroll-area"
data-variant="outlined"
class="notes"
>
<h3>2.4</h3>
<p>Offline sync for notes; conflicts are shown side by side.</p>
<h3>2.3</h3>
<p>Shared folders with read-only members.</p>
<h3>2.2</h3>
<p>Search across attachments, including scanned pages.</p>
<h3>2.1</h3>
<p>Keyboard shortcuts for every command in the editor.</p>
<h3>2.0</h3>
<p>A new editor with tables, checklists and code blocks.</p>
<h3>1.9</h3>
<p>Exports to Markdown and HTML.</p>
<h3>1.8</h3>
<p>Reminders on notes, with a daily digest.</p>
</div>
<style>
/* The page gives the area its size. */
.notes {
max-block-size: 14rem;
max-inline-size: 28rem;
padding: var(--slean-space-4);
}
.notes h3 {
margin: var(--slean-space-4) 0 var(--slean-space-1);
font-size: var(--slean-text-md);
}
.notes h3:first-child {
margin-block-start: 0;
}
.notes p {
margin: 0;
}
</style>Examples
Horizontal
- Harbor Shipping dashboard
- Lighthouse Status page
- Breakwater Rate limiter
- Tidewater Data pipeline
- Mooring Feature flags
- Quayside Billing portal
Code
<script lang="ts">
import '@svelte-lean/styles/scroll-area.css';
</script>
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
<div
role="region"
aria-label="Recent projects"
tabindex="0"
data-slean="scroll-area"
data-slean-orientation="horizontal"
>
<ul class="row">
<li><strong>Harbor</strong> Shipping dashboard</li>
<li><strong>Lighthouse</strong> Status page</li>
<li><strong>Breakwater</strong> Rate limiter</li>
<li><strong>Tidewater</strong> Data pipeline</li>
<li><strong>Mooring</strong> Feature flags</li>
<li><strong>Quayside</strong> Billing portal</li>
</ul>
</div>
<style>
.row {
display: flex;
gap: var(--slean-space-3);
margin: 0;
padding: var(--slean-space-3);
list-style: none;
}
.row li {
display: grid;
gap: var(--slean-space-1);
flex: none;
inline-size: 11rem;
padding: var(--slean-space-6) var(--slean-space-4);
border: 1px solid var(--slean-border);
border-radius: var(--slean-radius-md);
font-size: var(--slean-text-sm);
}
</style>Edge fades
Code
<script lang="ts">
import '@svelte-lean/styles/scroll-area.css';
const modules = ['Overview', 'Operators', 'Players', 'Payments', 'Bets', 'Transactions', 'Documents', 'Journal', 'Campaigns', 'Promotions', 'Content', 'Files', 'Reports', 'Settings'];
</script>
<!-- Any element that scrolls: the content fades at the edges it can still scroll towards. -->
<nav aria-label="Modules" data-slean-fade class="modules">
<ul>
{#each modules as module, i (module)}
<li><a href="/modules/{module}" aria-current={i === 0 ? 'page' : undefined}>{module}</a></li>
{/each}
</ul>
</nav>
<style>
.modules {
max-block-size: 14rem;
max-inline-size: 16rem;
overflow-y: auto;
}
.modules ul {
margin: 0;
padding: 0;
list-style: none;
}
.modules a {
display: block;
padding: var(--slean-space-2) var(--slean-space-3);
border-radius: var(--slean-radius-sm);
color: inherit;
text-decoration: none;
}
.modules a[aria-current] {
background: var(--slean-primary-soft);
color: var(--slean-primary-soft-text);
}
</style>Wide table
| Number | Customer | Status | Due | Amount | Currency |
|---|---|---|---|---|---|
| INV-1041 | Northwind Traders | Paid | 12 Sep 2026 | 1,280.00 | EUR |
| INV-1042 | Contoso Ltd | Pending | 18 Sep 2026 | 940.50 | USD |
| INV-1043 | Fabrikam Inc | Overdue | 21 Sep 2026 | 3,100.00 | USD |
| INV-1044 | Tailspin Toys | Paid | 27 Sep 2026 | 415.75 | GBP |
Code
<script lang="ts">
import '@svelte-lean/styles/scroll-area.css';
</script>
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
<div
role="region"
aria-labelledby="scroll-invoices-caption"
tabindex="0"
data-slean="scroll-area"
data-slean-orientation="horizontal"
data-variant="outlined"
>
<table class="invoices">
<caption id="scroll-invoices-caption">Invoices</caption>
<thead>
<tr><th>Number</th><th>Customer</th><th>Status</th><th>Due</th><th>Amount</th><th>Currency</th></tr>
</thead>
<tbody>
<tr><td>INV-1041</td><td>Northwind Traders</td><td>Paid</td><td>12 Sep 2026</td><td>1,280.00</td><td>EUR</td></tr>
<tr><td>INV-1042</td><td>Contoso Ltd</td><td>Pending</td><td>18 Sep 2026</td><td>940.50</td><td>USD</td></tr>
<tr><td>INV-1043</td><td>Fabrikam Inc</td><td>Overdue</td><td>21 Sep 2026</td><td>3,100.00</td><td>USD</td></tr>
<tr><td>INV-1044</td><td>Tailspin Toys</td><td>Paid</td><td>27 Sep 2026</td><td>415.75</td><td>GBP</td></tr>
</tbody>
</table>
</div>
<style>
.invoices {
min-inline-size: 44rem;
border-collapse: collapse;
font-size: var(--slean-text-sm);
}
.invoices caption {
padding: var(--slean-space-3) var(--slean-space-4) 0;
font-weight: var(--slean-font-weight-medium);
text-align: start;
}
.invoices :is(th, td) {
padding: var(--slean-space-2) var(--slean-space-4);
text-align: start;
white-space: nowrap;
}
</style>Many small areas
Members
- Amara Okafor
- Daniel Kim
- Elif Yıldız
- Hugo Martin
- Ines Costa
- Kai Nakamura
- Lena Vogel
- Mateo Ruiz
Channels
- #general
- #design
- #engineering
- #releases
- #support
- #random
- #hiring
- #events
Code
<script lang="ts">
import '@svelte-lean/styles/scroll-area.css';
const lists = [
{ id: 'scroll-members', title: 'Members', items: ['Amara Okafor', 'Daniel Kim', 'Elif Yıldız', 'Hugo Martin', 'Ines Costa', 'Kai Nakamura', 'Lena Vogel', 'Mateo Ruiz'] },
{ id: 'scroll-channels', title: 'Channels', items: ['#general', '#design', '#engineering', '#releases', '#support', '#random', '#hiring', '#events'] }
];
</script>
<!-- Many small areas: role="group" names each one without adding a landmark. -->
<div class="lists">
{#each lists as list (list.id)}
<div>
<p id={list.id}>{list.title}</p>
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
<div
role="group"
aria-labelledby={list.id}
tabindex="0"
data-slean="scroll-area"
data-variant="outlined"
>
<ul>
{#each list.items as item (item)}
<li>{item}</li>
{/each}
</ul>
</div>
</div>
{/each}
</div>
<style>
.lists {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
gap: var(--slean-space-4);
max-inline-size: 28rem;
font-size: var(--slean-text-sm);
}
.lists p {
margin: 0 0 var(--slean-space-1);
font-weight: var(--slean-font-weight-medium);
}
.lists [data-slean='scroll-area'] {
max-block-size: 8rem;
}
.lists ul {
margin: 0;
padding: var(--slean-space-2) var(--slean-space-3);
list-style: none;
line-height: 1.8;
}
</style>Usage
Plain markup with a stylesheet: install @svelte-lean/styles. No JavaScript runs.
npm install @svelte-lean/stylespnpm add @svelte-lean/stylesyarn add @svelte-lean/stylesbun add @svelte-lean/stylesimport '@svelte-lean/styles/scroll-area.css';Give the region its size from the page: a max-block-size for a vertical area, content wider than the region for a horizontal one (data-slean-orientation="horizontal"). Name it with aria-label, or aria-labelledby pointing at a visible title, and keep tabindex="0".
Use role="group" instead of region when a page has many small scroll areas, since each named region is a landmark. data-variant="outlined" adds a border and the surface color; content with its own opaque background covers the shadows.
data-slean-fade (or data-slean-fade="inline") fades the content itself at the edges that can still scroll, in place of the shadows, so it shows over any background. It goes on any element that scrolls, a sidebar’s <nav> or a list in a card, not only on a scroll area; not on an element with an animation of its own, such as a popover, but on the list inside it. Its depth is --slean-fade-size.
Anatomy
| Part | Element | data-slean-part | Required | Notes |
|---|---|---|---|---|
| root | <div role="region" aria-label="…" tabindex="0" data-slean="scroll-area"> | – | yes | data-slean-orientation="vertical|horizontal"; data-variant="outlined". The page sets its block size or max. |
Keyboard
| Key | When | Result |
|---|---|---|
| Tab | anywhere | Reaches the region (tabindex="0") |
| ArrowDown/ArrowUp | focus on the region | Scrolls by a line (native) |
| ArrowRight/ArrowLeft | focus on the region | Scrolls sideways by a line (native) |
| PageDown/PageUp/Space | focus on the region | Scrolls by a page (native) |
| Home/End | focus on the region | Scrolls to the start or the end (native) |
Styling
scroll-area.css sets the scrollbar width, colors and gutter, the overscroll containment per axis, the outline variant, the scroll-driven edge shadows and the edge fades. The tokens it reads:
| Token | Default (light) | Applies to |
|---|---|---|
--slean-border-strong | var(--slean-neutral-8) | scrollbar-color |
--slean-radius-md | var(--slean-radius) | border-radius |
--slean-border | var(--slean-neutral-6) | border |
--slean-surface | oklch(100% 0 0) | background |
--slean-fg | var(--slean-neutral-12) | color |
--slean-overlay | oklch(0% 0 0 / 0.4) | box-shadow |
--slean-fade-ramp | oklch(0% 0 0 / 0.08), oklch(0% 0 0 / 0.55) calc(var(--slean-fade-size) / 2), oklch(0% 0 0) var(--slean-fade-size) | mask-image |
--slean-fade-size | 1.5rem | mask-position, mask-size, animation-range |
State selectors the stylesheet targets, all from the platform or ARIA: :dir(rtl).
Variant attributes: data-slean-orientation (horizontal); data-variant (outlined); data-slean-fade (inline).
Under the hood
Runtime and size
- Tier
- 0 · Native
- Behavior JS
- 0 B brotli · 0 B gzip ·
fixtures/· methodresults.json (native-only) - Platform features
overflow: auto,tabindex="0",scrollbar-width,scrollbar-color,scrollbar-gutter,overscroll-behavior,animation-timeline: scroll()- Shared listeners
- none
- Per-instance listeners
- none
- Lazy state
- none
- Native base
overflow: auto + tabindex="0" in role="region"
Tier 0: the scroll area has no behavior module, the Vite plugin maps scroll-area to no module, and the page ships no Svelte Lean JavaScript for it.
Why this implementation
Every scrolling region is already a native component: overflow: auto scrolls, the browser draws the scrollbars, and the arrow keys, PageDown, Space, Home and End scroll a focused region. What a region with only text inside lacks is a way to receive focus in every browser, and a name for the screen reader that lands on it. tabindex="0" and role="region" with aria-label give it both.
Libraries replace the scrollbar with elements of their own to style it; the platform now styles the real one. scroll-area.css sets scrollbar-width: thin, scrollbar-color from the tokens and scrollbar-gutter: stable, contains overscroll on the scrolling axis, and, where scroll-driven animations exist, drives inset shadows from the region’s own scroll timeline.
The browser owns
- scrolling, the scrollbars and their dragging
- the scrolling keys: arrows, PageUp, PageDown, Space, Home, End
- the tab stop from tabindex="0" and the announcement of the named region
- scroll chaining and its containment, the scroll timeline behind the shadows
Svelte Lean owns
- scroll-area.css: thin token-colored scrollbars, a stable gutter, overscroll contained on one axis
- the edge shadows under @supports, mirrored under RTL
- the contract: the name, the role and the tab stop a scrolling region needs
- documentation
Accessibility
tabindex="0"makes the region a tab stop in every browser, so a keyboard user can scroll it when it holds nothing focusable.role="region"(orgroup) with a name: a focusable element needs one, and it is announced when focus lands on the region.- The scrolling keys are the browser’s: arrows, PageUp, PageDown, Space, Home and End.
- The scrollbars are the platform’s, so their pointer behavior, their size in the system settings and forced colors are unchanged.
Platform features
| Feature | Baseline | Outside the target |
|---|---|---|
scrollbar-width | Baseline 2024 (Safari 18.2) | Safari before 18.2 draws its default scrollbar |
scrollbar-color | Baseline 2025 (Safari 26.2) | Safari before 26.2 keeps the system colors |
scrollbar-gutter | Baseline 2024 | The content shifts when the scrollbar appears |
overscroll-behavior: contain | Not Baseline (Chrome 63, Firefox 59, Safari 16 on scrolling containers) | The page scrolls on when the area reaches its end |
Scroll-driven animations | Not Baseline (Chrome 115, Safari 26) | No edge shadows; the area scrolls the same |
Without JavaScript
Fully functional: scrolling, the keyboard and the scrollbars are native.
Server rendering and hydration
Static markup. The region starts at the beginning of its content.
Nothing is attached; the area scrolls before and after hydration alike.
Compatibility
scrollbar-width and scrollbar-gutter are Baseline 2024 (Safari 18.2) and scrollbar-color Baseline 2025 (Safari 26.2); older Safari keeps its default scrollbar. overscroll-behavior works on scrolling containers in every current engine but is not listed as Baseline, because engines differ on containers without overflow. Scroll-driven animations are not Baseline (Chrome 115, Safari 26, not Firefox): without them there are no edge shadows.
Tests and source
apps/playground/tests/primitives/display-extra.spec.tsPlaywright, with page JavaScript enabled and disabled: roles, names, keyboard, geometry, axepackages/styles/testsstatic checks of the stylesheet (layers, tokens, specificity, dark parity)
packages/primitives/src/scroll-area/contract.mdthe contract in prose: semantics, keyboard, focus, ARIA, SSR, JS-disabled behaviorpackages/primitives/src/scroll-area/contract.tstyped constants: name, tier, base, parts, options, eventspackages/styles/css/scroll-area.cssthe optional stylesheet