ScrollArea New Alpha

Open in Storybook

A scroll container with custom, consistently-styled scrollbars and optional edge fades.

OverviewUsageCompositionExamplesAccessibilityAPI reference
This component is considered alpha. We're still finalising the API, so it may include a breaking change at any time — use it at your own risk.
Loading...

Usage

Scroll Area wraps overflowing content in a custom scroll viewport. Native scrollbars are hidden and replaced with a thin overlay thumb that appears on hover or while scrolling — consistent across platforms and browsers.

Import the component — the import registers the custom element:

Copy code
import "@nordhealth/components/lib/ScrollArea"

Then wrap your content and give the area a size:

Composition

Scroll Area is a single element. Slot your content directly inside it; the viewport, scrollbars, thumbs and corner are rendered internally in shadow DOM and exposed as parts.

Copy code
nord-scroll-area
├── ::part(viewport)          the scrolling container (your slotted content)
├── ::part(scrollbar-block)   vertical scrollbar track
│   └── ::part(thumb-block)
├── ::part(scrollbar-inline)  horizontal scrollbar track
│   └── ::part(thumb-inline)
└── ::part(corner)            where the two scrollbars meet (axis="both")
Copy code
<nord-scroll-area axis="both" style="block-size: 12rem">
  <!-- your content -->
</nord-scroll-area>

The axis attribute controls which scrollbars are rendered: block (vertical, the default), inline (horizontal), or both.

Add the fade attribute for a built-in edge fade (see the Edge fade example). Scroll Area also publishes the distance scrolled from each edge as the read-only CSS custom properties --scroll-area-overflow-y-start, --scroll-area-overflow-y-end, --scroll-area-overflow-x-start and --scroll-area-overflow-x-end on ::part(viewport), so advanced consumers can drive their own masks or effects.

Examples

Horizontal

Set axis="inline" for a horizontally scrolling area.

Both scrollbars

Set axis="both" when content overflows on both axes. A corner fills the space where the scrollbars meet.

Edge fade

Add the fade attribute to fade content in and out at the scroll edges, signalling there is more content beyond the edge. Tune the depth with the --n-scroll-area-fade-size custom property.

With axis="both", all four edges fade independently — each side fades only when there is more content beyond it.

RTL

Scroll Area is direction-aware. In a right-to-left context the block (vertical) scrollbar moves to the inline-start (left) edge.

Accessibility

  • The viewport is a natively scrollable region, so keyboard scrolling (arrow keys, Page Up / Page Down, Home / End) works without custom handling, and the viewport stays in the tab order while it overflows.
  • Give the area an aria-label when its purpose isn't already conveyed by a nearby heading, so screen reader users understand what the scrollable region contains.
  • On touch devices (pointer: coarse) the custom scrollbar is suppressed and the platform's native scrolling takes over.

API reference

ScrollArea

Scroll Area is a container that wraps overflowing content in a custom scroll viewport with consistently-styled scrollbars. Native scrollbars are hidden and replaced with a thin overlay thumb that appears on hover or while scrolling. It also exposes the distance from each edge as CSS custom properties (--scroll-area-overflow-*), which can drive an edge-fade mask on ::part(viewport) — see the docs example. The scroll machinery lives in shadow DOM; slot your content directly inside.

<nord-scroll-area></nord-scroll-area>

Props

PropertyAttribute Description TypeDefault
axisaxisWhich scrollbars to render. block is vertical, inline is horizontal.'block' | 'inline' | 'both''block'
overflowEdgeThresholdoverflow-edge-thresholdDistance in pixels past an edge before the matching data-overflow-* state (and edge-fade variable) is considered active.number0
fadefadeFades the content in and out at the scroll edges with a mask, signalling there is more content beyond the edge.booleanfalse
alwaysShowScrollbaralways-show-scrollbarAlways display the scrollbar instead of hiding it when idle.booleanfalse

Slots

Slot name Description
Default slotThe scrollable content.

CSS Properties

CSS Custom Properties provide more fine grain control over component presentation. We advise utilizing existing properties on the component before using these.

PropertyDescriptionDefault
--n-scroll-area-fade-sizeDepth of the edge fade (when fade is set).24px
--n-scroll-area-scrollbar-sizeThickness of the scrollbar track and thumb.10px
--n-scroll-area-scrollbar-insetInset of the scrollbar from the viewport edge.2px
--n-scroll-area-thumb-colorThumb fill (defaults to the border token).
--n-scroll-area-thumb-color-hoverThumb fill on hover (defaults to the strong border token).
--scroll-area-overflow-y-startRead-only: pixels scrolled past the block start edge.
--scroll-area-overflow-y-endRead-only: pixels remaining to the block end edge.
--scroll-area-overflow-x-startRead-only: pixels scrolled past the inline start edge.
--scroll-area-overflow-x-endRead-only: pixels remaining to the inline end edge.

Was this page helpful?

Yes No

We use this feedback to improve our documentation.