Skip to content
Nana UI

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.

View .md Download

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.

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
Motor
Home
Health
Travel
Life
Marine
Crop
Livestock

Recent claims

  • CLM-2041 Wanjiru Kamau KES 48,500
  • CLM-2040 Otieno Ouma KES 47,250
  • CLM-2039 Achieng Odhiambo KES 46,000
  • CLM-2038 Kiprop Rotich KES 44,750
  • CLM-2037 Wanjiru Kamau KES 43,500
  • CLM-2036 Otieno Ouma KES 42,250
  • CLM-2035 Achieng Odhiambo KES 41,000
  • CLM-2034 Kiprop Rotich KES 39,750
  • CLM-2033 Wanjiru Kamau KES 38,500
  • CLM-2032 Otieno Ouma KES 37,250
  • CLM-2031 Achieng Odhiambo KES 36,000
  • CLM-2030 Kiprop Rotich KES 34,750
  • CLM-2029 Wanjiru Kamau KES 33,500
  • CLM-2028 Otieno Ouma KES 32,250
  • CLM-2027 Achieng Odhiambo KES 31,000
  • CLM-2026 Kiprop Rotich KES 29,750
  • CLM-2025 Wanjiru Kamau KES 28,500
  • CLM-2024 Otieno Ouma KES 27,250
  • CLM-2023 Achieng Odhiambo KES 26,000
  • CLM-2022 Kiprop Rotich KES 24,750
  • CLM-2021 Wanjiru Kamau KES 23,500
  • CLM-2020 Otieno Ouma KES 22,250
  • CLM-2019 Achieng Odhiambo KES 21,000
  • CLM-2018 Kiprop Rotich KES 19,750
Motor
Home
Health
Travel
Life
Marine
Crop
Livestock

Install the package for a versioned dependency:

npm install @nana-tec/ui-components

Or copy the source in and own it:

npx @nana-tec/ui add scroll-area --framework web-components
npx @nana-tec/ui add scroll-area --framework svelte

Lands 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 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 says when the scrollbars show:

ValueShows the scrollbars
hoverWhile the pointer is over the area, and while it scrolls. The default.
scrollOnly while it scrolls, fading out a moment after it stops.
autoWhenever the content overflows.
alwaysLikewise; 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.

  • 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 label and 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

PropertyAttributeTypeDefaultDescription
labellabelstring | undefined—Names the area for screen readers, which then announce it as a region.
orientationorientationScrollOrientation'vertical'Which way the content scrolls: vertical, horizontal or both.
scrollbarsscrollbarsScrollbarMode'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

SlotDescription
(default)The content that scrolls

CSS parts

PartDescription
::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

PropertyDescription
--nana-scroll-area-scrollbar-sizeHow thick the scrollbars are

NanaScrollArea

PropTypeDefault
orientationScrollOrientation'vertical'
scrollbarsScrollbarMode'hover'
labelstring
viewportbind:HTMLElement | nullnull
viewportClassstring''
childrenSnippet

Also accepts Omit<HTMLAttributes<HTMLDivElement>, 'class' | 'children'>.