Layout & Containers
Scroll Area
A scrolling region with slim scrollbars of its own, drawn over native scrolling so the wheel, touch and keyboard behave as they always do.
A scroll area keeps a long list or a wide row inside a fixed space, with scrollbars that look the same on every system and stay out of the way until they are wanted. The scrolling itself is the browser’s own, so the wheel, a trackpad, touch, the keyboard and find-in-page all work as people expect; only the scrollbars are drawn. For a whole page, let the page scroll; use this for a panel, a list or a row inside it.
Preview
Section titled “Preview”Recent claims
- CLM-2041Wanjiru KamauKES 48,500
- CLM-2040Otieno OumaKES 47,250
- CLM-2039Achieng OdhiamboKES 46,000
- CLM-2038Kiprop RotichKES 44,750
- CLM-2037Wanjiru KamauKES 43,500
- CLM-2036Otieno OumaKES 42,250
- CLM-2035Achieng OdhiamboKES 41,000
- CLM-2034Kiprop RotichKES 39,750
- CLM-2033Wanjiru KamauKES 38,500
- CLM-2032Otieno OumaKES 37,250
- CLM-2031Achieng OdhiamboKES 36,000
- CLM-2030Kiprop RotichKES 34,750
- CLM-2029Wanjiru KamauKES 33,500
- CLM-2028Otieno OumaKES 32,250
- CLM-2027Achieng OdhiamboKES 31,000
- CLM-2026Kiprop RotichKES 29,750
- CLM-2025Wanjiru KamauKES 28,500
- CLM-2024Otieno OumaKES 27,250
- CLM-2023Achieng OdhiamboKES 26,000
- CLM-2022Kiprop RotichKES 24,750
- CLM-2021Wanjiru KamauKES 23,500
- CLM-2020Otieno OumaKES 22,250
- CLM-2019Achieng OdhiamboKES 21,000
- CLM-2018Kiprop RotichKES 19,750
<div
style="
display: flex;
flex-direction: column;
gap: 1.5rem;
width: 100%;
max-width: 28rem;
"
>
<div
style="border: 1px solid var(--nana-surface-border); border-radius: 0.5rem"
>
<p
style="
margin: 0;
padding: 0.75rem 1rem;
border-bottom: 1px solid var(--nana-surface-border);
font-size: 0.875rem;
font-weight: 600;
"
>
Recent claims
</p>
<nana-scroll-area
label="Recent claims"
style="height: 18rem; border-radius: 0 0 0.5rem 0.5rem"
>
<ul style="margin: 0; padding: 0; list-style: none">
<li
style="
display: flex;
justify-content: space-between;
gap: 1rem;
padding: 0.625rem 1rem;
border-bottom: 1px solid var(--nana-surface-border);
font-size: 0.875rem;
line-height: 1.25rem;
"
>
<span>
<strong style="display: block; font-weight: 500">CLM-2041</strong>
<span style="color: var(--nana-surface-text-muted)">
Wanjiru Kamau
</span>
</span>
<span style="font-variant-numeric: tabular-nums">KES 48,500</span>
</li>
<li
style="
display: flex;
justify-content: space-between;
gap: 1rem;
padding: 0.625rem 1rem;
border-bottom: 1px solid var(--nana-surface-border);
font-size: 0.875rem;
line-height: 1.25rem;
"
>
<span>
<strong style="display: block; font-weight: 500">CLM-2040</strong>
<span style="color: var(--nana-surface-text-muted)">
Otieno Ouma
</span>
</span>
<span style="font-variant-numeric: tabular-nums">KES 47,250</span>
</li>
<li
style="
display: flex;
justify-content: space-between;
gap: 1rem;
padding: 0.625rem 1rem;
border-bottom: 1px solid var(--nana-surface-border);
font-size: 0.875rem;
line-height: 1.25rem;
"
>
<span>
<strong style="display: block; font-weight: 500">CLM-2039</strong>
<span style="color: var(--nana-surface-text-muted)">
Achieng Odhiambo
</span>
</span>
<span style="font-variant-numeric: tabular-nums">KES 46,000</span>
</li>
<li
style="
display: flex;
justify-content: space-between;
gap: 1rem;
padding: 0.625rem 1rem;
border-bottom: 1px solid var(--nana-surface-border);
font-size: 0.875rem;
line-height: 1.25rem;
"
>
<span>
<strong style="display: block; font-weight: 500">CLM-2038</strong>
<span style="color: var(--nana-surface-text-muted)">
Kiprop Rotich
</span>
</span>
<span style="font-variant-numeric: tabular-nums">KES 44,750</span>
</li>
<li
style="
display: flex;
justify-content: space-between;
gap: 1rem;
padding: 0.625rem 1rem;
border-bottom: 1px solid var(--nana-surface-border);
font-size: 0.875rem;
line-height: 1.25rem;
"
>
<span>
<strong style="display: block; font-weight: 500">CLM-2037</strong>
<span style="color: var(--nana-surface-text-muted)">
Wanjiru Kamau
</span>
</span>
<span style="font-variant-numeric: tabular-nums">KES 43,500</span>
</li>
<li
style="
display: flex;
justify-content: space-between;
gap: 1rem;
padding: 0.625rem 1rem;
border-bottom: 1px solid var(--nana-surface-border);
font-size: 0.875rem;
line-height: 1.25rem;
"
>
<span>
<strong style="display: block; font-weight: 500">CLM-2036</strong>
<span style="color: var(--nana-surface-text-muted)">
Otieno Ouma
</span>
</span>
<span style="font-variant-numeric: tabular-nums">KES 42,250</span>
</li>
<li
style="
display: flex;
justify-content: space-between;
gap: 1rem;
padding: 0.625rem 1rem;
border-bottom: 1px solid var(--nana-surface-border);
font-size: 0.875rem;
line-height: 1.25rem;
"
>
<span>
<strong style="display: block; font-weight: 500">CLM-2035</strong>
<span style="color: var(--nana-surface-text-muted)">
Achieng Odhiambo
</span>
</span>
<span style="font-variant-numeric: tabular-nums">KES 41,000</span>
</li>
<li
style="
display: flex;
justify-content: space-between;
gap: 1rem;
padding: 0.625rem 1rem;
border-bottom: 1px solid var(--nana-surface-border);
font-size: 0.875rem;
line-height: 1.25rem;
"
>
<span>
<strong style="display: block; font-weight: 500">CLM-2034</strong>
<span style="color: var(--nana-surface-text-muted)">
Kiprop Rotich
</span>
</span>
<span style="font-variant-numeric: tabular-nums">KES 39,750</span>
</li>
<li
style="
display: flex;
justify-content: space-between;
gap: 1rem;
padding: 0.625rem 1rem;
border-bottom: 1px solid var(--nana-surface-border);
font-size: 0.875rem;
line-height: 1.25rem;
"
>
<span>
<strong style="display: block; font-weight: 500">CLM-2033</strong>
<span style="color: var(--nana-surface-text-muted)">
Wanjiru Kamau
</span>
</span>
<span style="font-variant-numeric: tabular-nums">KES 38,500</span>
</li>
<li
style="
display: flex;
justify-content: space-between;
gap: 1rem;
padding: 0.625rem 1rem;
border-bottom: 1px solid var(--nana-surface-border);
font-size: 0.875rem;
line-height: 1.25rem;
"
>
<span>
<strong style="display: block; font-weight: 500">CLM-2032</strong>
<span style="color: var(--nana-surface-text-muted)">
Otieno Ouma
</span>
</span>
<span style="font-variant-numeric: tabular-nums">KES 37,250</span>
</li>
<li
style="
display: flex;
justify-content: space-between;
gap: 1rem;
padding: 0.625rem 1rem;
border-bottom: 1px solid var(--nana-surface-border);
font-size: 0.875rem;
line-height: 1.25rem;
"
>
<span>
<strong style="display: block; font-weight: 500">CLM-2031</strong>
<span style="color: var(--nana-surface-text-muted)">
Achieng Odhiambo
</span>
</span>
<span style="font-variant-numeric: tabular-nums">KES 36,000</span>
</li>
<li
style="
display: flex;
justify-content: space-between;
gap: 1rem;
padding: 0.625rem 1rem;
border-bottom: 1px solid var(--nana-surface-border);
font-size: 0.875rem;
line-height: 1.25rem;
"
>
<span>
<strong style="display: block; font-weight: 500">CLM-2030</strong>
<span style="color: var(--nana-surface-text-muted)">
Kiprop Rotich
</span>
</span>
<span style="font-variant-numeric: tabular-nums">KES 34,750</span>
</li>
<li
style="
display: flex;
justify-content: space-between;
gap: 1rem;
padding: 0.625rem 1rem;
border-bottom: 1px solid var(--nana-surface-border);
font-size: 0.875rem;
line-height: 1.25rem;
"
>
<span>
<strong style="display: block; font-weight: 500">CLM-2029</strong>
<span style="color: var(--nana-surface-text-muted)">
Wanjiru Kamau
</span>
</span>
<span style="font-variant-numeric: tabular-nums">KES 33,500</span>
</li>
<li
style="
display: flex;
justify-content: space-between;
gap: 1rem;
padding: 0.625rem 1rem;
border-bottom: 1px solid var(--nana-surface-border);
font-size: 0.875rem;
line-height: 1.25rem;
"
>
<span>
<strong style="display: block; font-weight: 500">CLM-2028</strong>
<span style="color: var(--nana-surface-text-muted)">
Otieno Ouma
</span>
</span>
<span style="font-variant-numeric: tabular-nums">KES 32,250</span>
</li>
<li
style="
display: flex;
justify-content: space-between;
gap: 1rem;
padding: 0.625rem 1rem;
border-bottom: 1px solid var(--nana-surface-border);
font-size: 0.875rem;
line-height: 1.25rem;
"
>
<span>
<strong style="display: block; font-weight: 500">CLM-2027</strong>
<span style="color: var(--nana-surface-text-muted)">
Achieng Odhiambo
</span>
</span>
<span style="font-variant-numeric: tabular-nums">KES 31,000</span>
</li>
<li
style="
display: flex;
justify-content: space-between;
gap: 1rem;
padding: 0.625rem 1rem;
border-bottom: 1px solid var(--nana-surface-border);
font-size: 0.875rem;
line-height: 1.25rem;
"
>
<span>
<strong style="display: block; font-weight: 500">CLM-2026</strong>
<span style="color: var(--nana-surface-text-muted)">
Kiprop Rotich
</span>
</span>
<span style="font-variant-numeric: tabular-nums">KES 29,750</span>
</li>
<li
style="
display: flex;
justify-content: space-between;
gap: 1rem;
padding: 0.625rem 1rem;
border-bottom: 1px solid var(--nana-surface-border);
font-size: 0.875rem;
line-height: 1.25rem;
"
>
<span>
<strong style="display: block; font-weight: 500">CLM-2025</strong>
<span style="color: var(--nana-surface-text-muted)">
Wanjiru Kamau
</span>
</span>
<span style="font-variant-numeric: tabular-nums">KES 28,500</span>
</li>
<li
style="
display: flex;
justify-content: space-between;
gap: 1rem;
padding: 0.625rem 1rem;
border-bottom: 1px solid var(--nana-surface-border);
font-size: 0.875rem;
line-height: 1.25rem;
"
>
<span>
<strong style="display: block; font-weight: 500">CLM-2024</strong>
<span style="color: var(--nana-surface-text-muted)">
Otieno Ouma
</span>
</span>
<span style="font-variant-numeric: tabular-nums">KES 27,250</span>
</li>
<li
style="
display: flex;
justify-content: space-between;
gap: 1rem;
padding: 0.625rem 1rem;
border-bottom: 1px solid var(--nana-surface-border);
font-size: 0.875rem;
line-height: 1.25rem;
"
>
<span>
<strong style="display: block; font-weight: 500">CLM-2023</strong>
<span style="color: var(--nana-surface-text-muted)">
Achieng Odhiambo
</span>
</span>
<span style="font-variant-numeric: tabular-nums">KES 26,000</span>
</li>
<li
style="
display: flex;
justify-content: space-between;
gap: 1rem;
padding: 0.625rem 1rem;
border-bottom: 1px solid var(--nana-surface-border);
font-size: 0.875rem;
line-height: 1.25rem;
"
>
<span>
<strong style="display: block; font-weight: 500">CLM-2022</strong>
<span style="color: var(--nana-surface-text-muted)">
Kiprop Rotich
</span>
</span>
<span style="font-variant-numeric: tabular-nums">KES 24,750</span>
</li>
<li
style="
display: flex;
justify-content: space-between;
gap: 1rem;
padding: 0.625rem 1rem;
border-bottom: 1px solid var(--nana-surface-border);
font-size: 0.875rem;
line-height: 1.25rem;
"
>
<span>
<strong style="display: block; font-weight: 500">CLM-2021</strong>
<span style="color: var(--nana-surface-text-muted)">
Wanjiru Kamau
</span>
</span>
<span style="font-variant-numeric: tabular-nums">KES 23,500</span>
</li>
<li
style="
display: flex;
justify-content: space-between;
gap: 1rem;
padding: 0.625rem 1rem;
border-bottom: 1px solid var(--nana-surface-border);
font-size: 0.875rem;
line-height: 1.25rem;
"
>
<span>
<strong style="display: block; font-weight: 500">CLM-2020</strong>
<span style="color: var(--nana-surface-text-muted)">
Otieno Ouma
</span>
</span>
<span style="font-variant-numeric: tabular-nums">KES 22,250</span>
</li>
<li
style="
display: flex;
justify-content: space-between;
gap: 1rem;
padding: 0.625rem 1rem;
border-bottom: 1px solid var(--nana-surface-border);
font-size: 0.875rem;
line-height: 1.25rem;
"
>
<span>
<strong style="display: block; font-weight: 500">CLM-2019</strong>
<span style="color: var(--nana-surface-text-muted)">
Achieng Odhiambo
</span>
</span>
<span style="font-variant-numeric: tabular-nums">KES 21,000</span>
</li>
<li
style="
display: flex;
justify-content: space-between;
gap: 1rem;
padding: 0.625rem 1rem;
border-bottom: 1px solid var(--nana-surface-border);
font-size: 0.875rem;
line-height: 1.25rem;
"
>
<span>
<strong style="display: block; font-weight: 500">CLM-2018</strong>
<span style="color: var(--nana-surface-text-muted)">
Kiprop Rotich
</span>
</span>
<span style="font-variant-numeric: tabular-nums">KES 19,750</span>
</li>
</ul>
</nana-scroll-area>
</div>
<nana-scroll-area
label="Policy types"
orientation="horizontal"
style="border-radius: 0.5rem"
>
<div style="display: flex; gap: 0.75rem; padding-bottom: 1rem">
<div
style="
display: flex;
align-items: flex-end;
flex-shrink: 0;
width: 9rem;
height: 6rem;
padding: 0.75rem;
border: 1px solid var(--nana-surface-border);
border-radius: 0.5rem;
background: var(--nana-surface-muted);
font-size: 0.875rem;
font-weight: 500;
"
>
Motor
</div>
<div
style="
display: flex;
align-items: flex-end;
flex-shrink: 0;
width: 9rem;
height: 6rem;
padding: 0.75rem;
border: 1px solid var(--nana-surface-border);
border-radius: 0.5rem;
background: var(--nana-surface-muted);
font-size: 0.875rem;
font-weight: 500;
"
>
Home
</div>
<div
style="
display: flex;
align-items: flex-end;
flex-shrink: 0;
width: 9rem;
height: 6rem;
padding: 0.75rem;
border: 1px solid var(--nana-surface-border);
border-radius: 0.5rem;
background: var(--nana-surface-muted);
font-size: 0.875rem;
font-weight: 500;
"
>
Health
</div>
<div
style="
display: flex;
align-items: flex-end;
flex-shrink: 0;
width: 9rem;
height: 6rem;
padding: 0.75rem;
border: 1px solid var(--nana-surface-border);
border-radius: 0.5rem;
background: var(--nana-surface-muted);
font-size: 0.875rem;
font-weight: 500;
"
>
Travel
</div>
<div
style="
display: flex;
align-items: flex-end;
flex-shrink: 0;
width: 9rem;
height: 6rem;
padding: 0.75rem;
border: 1px solid var(--nana-surface-border);
border-radius: 0.5rem;
background: var(--nana-surface-muted);
font-size: 0.875rem;
font-weight: 500;
"
>
Life
</div>
<div
style="
display: flex;
align-items: flex-end;
flex-shrink: 0;
width: 9rem;
height: 6rem;
padding: 0.75rem;
border: 1px solid var(--nana-surface-border);
border-radius: 0.5rem;
background: var(--nana-surface-muted);
font-size: 0.875rem;
font-weight: 500;
"
>
Marine
</div>
<div
style="
display: flex;
align-items: flex-end;
flex-shrink: 0;
width: 9rem;
height: 6rem;
padding: 0.75rem;
border: 1px solid var(--nana-surface-border);
border-radius: 0.5rem;
background: var(--nana-surface-muted);
font-size: 0.875rem;
font-weight: 500;
"
>
Crop
</div>
<div
style="
display: flex;
align-items: flex-end;
flex-shrink: 0;
width: 9rem;
height: 6rem;
padding: 0.75rem;
border: 1px solid var(--nana-surface-border);
border-radius: 0.5rem;
background: var(--nana-surface-muted);
font-size: 0.875rem;
font-weight: 500;
"
>
Livestock
</div>
</div>
</nana-scroll-area>
</div> Recent claims
<script lang="ts">
import { NanaScrollArea } from '$lib';
const claims = Array.from({ length: 24 }, (_, index) => ({
id: `CLM-${2041 - index}`,
holder: ['Wanjiru Kamau', 'Otieno Ouma', 'Achieng Odhiambo', 'Kiprop Rotich'][index % 4],
amount: (48_500 - index * 1_250).toLocaleString('en-KE'),
}));
const policies = ['Motor', 'Home', 'Health', 'Travel', 'Life', 'Marine', 'Crop', 'Livestock'];
</script>
<div class="flex w-full max-w-md flex-col gap-6">
<div class="rounded-lg border border-line">
<p class="border-b border-line px-4 py-3 text-sm font-semibold text-foreground">
Recent claims
</p>
<NanaScrollArea label="Recent claims" class="h-72 rounded-b-lg">
<ul>
{#each claims as claim (claim.id)}
<li
class="flex justify-between gap-4 border-b border-line px-4 py-2.5 text-sm last:border-b-0"
>
<span>
<span class="block font-medium text-foreground">{claim.id}</span>
<span class="text-foreground-muted">{claim.holder}</span>
</span>
<span class="text-foreground tabular-nums">KES {claim.amount}</span>
</li>
{/each}
</ul>
</NanaScrollArea>
</div>
<NanaScrollArea label="Policy types" orientation="horizontal" class="rounded-lg">
<div class="flex gap-3 pb-4">
{#each policies as policy (policy)}
<div
class="flex h-24 w-36 shrink-0 items-end rounded-lg border border-line bg-surface-muted p-3 text-sm font-medium text-foreground"
>
{policy}
</div>
{/each}
</div>
</NanaScrollArea>
</div> Installation
Section titled “Installation”Install the package for a versioned dependency:
npm install @nana-tec/ui-componentsOr copy the source in and own it:
npx @nana-tec/ui add scroll-area --framework web-componentsnpx @nana-tec/ui add scroll-area --framework svelteLands in src/lib/components/ui/scroll-area/ as NanaScrollArea.svelte, styled with
Tailwind classes that resolve to the design tokens. Requires Tailwind v4.
Give the area a height, or a maximum height so it grows with short content and scrolls once the content outgrows it, then put the content inside.
<script lang="ts"> import { NanaScrollArea } from '$lib/components/ui/scroll-area';</script>
<NanaScrollArea label="Recent claims" class="max-h-72"> <ul> <!-- … --> </ul></NanaScrollArea>Bind viewport to read or set the scroll position from code, and pass viewportClass
for classes on the element that scrolls.
Import the autoloader once, in your app's entry point. Every <nana-*> tag then works anywhere, and
each component downloads only the first time a page uses it:
import "@nana-tec/ui-components/autoloader";import "@nana-tec/ui-components/theme";The second line gives every component the Nana look and the design tokens behind it. Leave it out to style the components entirely yourself.
Import a component directly when it must be ready at once: on screen at first paint, or when you call its methods straight away. The two mix freely:
import "@nana-tec/ui-components/scroll-area";
Copied in with npx @nana-tec/ui add scroll-area? Import your project's own
@/lib/nana-ui/autoloader.js once instead; the CLI keeps it up to date.
<nana-scroll-area label="Recent claims" style="max-height: 18rem"> <ul> <!-- … --> </ul></nana-scroll-area>The viewport property is the element that scrolls, for reading or setting its scroll
position, and --nana-scroll-area-scrollbar-size sets how thick the scrollbars are.
Orientation
Section titled “Orientation”orientation is vertical by default. Set horizontal for a row wider than its space,
as in the policy cards above, or both for a table or a canvas that runs both ways;
the two scrollbars then leave a corner between them.
Scrollbars
Section titled “Scrollbars”scrollbars says when the scrollbars show:
| Value | Shows the scrollbars |
|---|---|
hover | While the pointer is over the area, and while it scrolls. The default. |
scroll | Only while it scrolls, fading out a moment after it stops. |
auto | Whenever the content overflows. |
always | Likewise; it never hides them while there is something to scroll. |
With nothing to scroll there is no scrollbar, whatever the setting. Dragging a thumb scrolls, a press in a track jumps there, and a wheel over a scrollbar scrolls the content.
Accessibility
Section titled “Accessibility”- With something to scroll, the area joins the tab order, so keyboard users can focus it and scroll with the arrow keys, Page Up and Page Down, Home and End, and Space. With nothing to scroll it stays out of the way.
- Give it a
labeland screen readers announce it as a named region. - The drawn scrollbars are hidden from screen readers; the content scrolls the way it always does for them.
- The scrollbars fade without motion when the reader prefers reduced motion.
Properties
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
label | label | string | undefined | — | Names the area for screen readers, which then announce it as a region. |
orientation | orientation | ScrollOrientation | 'vertical' | Which way the content scrolls: vertical, horizontal or both. |
scrollbars | scrollbars | ScrollbarMode | 'hover' | When the scrollbars show: hover while the pointer is over the area or it is scrolling, scroll only while it is scrolling, auto whenever there is overflow, always likewise. |
Slots
| Slot | Description |
|---|---|
(default) | The content that scrolls |
CSS parts
| Part | Description |
|---|---|
::part(base) | The wrapper around everything |
::part(viewport) | The element that scrolls |
::part(content) | The wrapper around the slotted content |
::part(scrollbar) | A scrollbar, with vertical or horizontal, and visible while shown |
::part(thumb) | A scrollbar's thumb, with vertical or horizontal |
::part(corner) | The square where two scrollbars meet |
CSS custom properties
| Property | Description |
|---|---|
--nana-scroll-area-scrollbar-size | How thick the scrollbars are |
NanaScrollArea
| Prop | Type | Default |
|---|---|---|
orientation | ScrollOrientation | 'vertical' |
scrollbars | ScrollbarMode | 'hover' |
label | string | |
viewportbind: | HTMLElement | null | null |
viewportClass | string | '' |
children | Snippet |
Also accepts Omit<HTMLAttributes<HTMLDivElement>, 'class' | 'children'>.