Skip to main content
Login

Sign in to access your account

Scroll More - National Design System

A general-purpose overflow wrapper that auto-detects its scroll axis, fades the edges of clipped content, and shows a sticky button to paginate through the rest.

Overview

Scroll More fits long content into a set height or width. The wrapper is nds-scroll-more, and the part that scrolls is nds-scroll-more-content. When the content does not fit, its edges fade, and an optional nds-show-more button moves it on one page at a time. The script finds the scroll direction by itself.

Pick another component when:

  • the items are tabs: Tabs, which scroll their own tab row
  • a “Show all” button is enough and paging is not needed: Expandable Content
  • the content is a menu with levels: Drawer

Markup

Preview
  • Riyadh
  • Jeddah
  • Makkah
  • Madinah
  • Dammam
  • Khobar
  • Taif
  • Tabuk
  • Abha
  • Buraydah
  • Khamis Mushait
  • Hail
<div class="nds-scroll-more nds-fit"> <ul class="nds-scroll-more-content"> <li>Riyadh</li> <li>Jeddah</li> <li>Makkah</li> <li>Madinah</li> <li>Dammam</li> <li>Khobar</li> <li>Taif</li> <li>Tabuk</li> <li>Abha</li> <li>Buraydah</li> <li>Khamis Mushait</li> <li>Hail</li> </ul> <button type="button" class="nds-btn nds-subtle nds-md nds-show-more"> <span class="nds-label" data-i18n="scroll-more.show_more">Show more</span> <i class="nds-icon nds-hgi-arrow-down-01" aria-hidden="true"></i> </button> </div>

Built-in Features

  • Auto-initialization

    Every .nds-scroll-more on the page starts by itself. The overflow check, the scroll listener and the button need no call.

  • Axis Auto-detection

    The script measures both directions and scrolls the one that overflows. When both do, it scrolls vertically.

  • Edge Fade Mask

    An edge fades only while more content lies past it, so there is no fade at the very start or the very end.

  • Item-aware Step

    Each click moves one page minus one item, so the last item stays in view as an anchor. The first item's size sets the step.

  • Loop to Start

    At the end, the button's arrow flips, and the next click scrolls back to the start.

  • Reactive to Layout

    The script checks the overflow again when the content area changes size, so the button shows and hides as needed.

  • Free-scroll Friendly

    Touch, trackpad and mouse-wheel scrolling work as usual. The scroll listener is passive and runs at most once a frame.

  • Keyboard Scroll

    Content that scrolls and holds no link or control gets tabindex="0", so a keyboard user can tab to it and scroll it with the arrow keys. A tabindex in your markup stays as written.

  • Programmatic Control

    Start a new wrapper, check the overflow again or remove the behavior through NDS.ScrollMore.

Best Practices

  • Use Scroll More to fit a long list, a row of chips or a card track into a set area, with every item still in reach.
  • Give a vertical list a height limit: nds-fit, --scroll-max-height, or a flex or grid parent with a set height. Without one, the list never overflows and the button never shows. A plain block parent with a set height does not hold the list: it grows past it.
  • For another height, set --scroll-max-height in your own stylesheet, not in a style attribute: a strict Content Security Policy blocks inline styles.
  • In a card beside a taller card, add nds-fit, so the list fills its card.
  • Keep the items the same size when you want even paging. The first item sets the step.
  • Keep the visible “Show more” label on the button. It names the button for screen readers.
  • Add nds-snap to a card track, so each click stops at the start of a card.
  • When items have borders or shadows that the edge clips, add inline padding to .nds-scroll-more-content.

API

Classes

Class Element Effect
nds-fit A vertical .nds-scroll-more Fills the height its parent gives it, and the items scroll in that height: a grid cell, a flex row, or a card beside a taller card. The parent must be a grid or a flex container. In a card, put the title in .nds-card-header: a .nds-card-text beside the list grows too and takes part of the height. With no height from the parent, such as stacked cards on a phone, the list takes --scroll-max-height. Not for a row or a card track: they already fill their container’s width

Data Attributes

The script writes these on the wrapper. Read them in your own CSS or script. Do not set them.

Attribute Element Effect
data-axis .nds-scroll-more vertical or horizontal: the direction that overflows. Removed when nothing overflows
data-state .nds-scroll-more has-more while the content overflows, at-start at the start of the scroll and at-end at the end. They drive the fade and the direction of the button’s arrow

CSS Custom Properties

Set these on the wrapper.

Property Default Controls
--scroll-max-height none Height limit of the wrapper, for vertical overflow. With nds-fit it is the least height, 240px when unset: the list grows past it to fill its parent
--scroll-max-width 100% Width limit of the wrapper, for horizontal overflow. The wrapper never grows past its container, whatever the value
--scroll-fade 16px Length of the edge fade
--scroll-gap 0 Space between the content and the button
--scroll-divider var(--divider-color) Color of the nds-divided hairline
--scroll-padding var(--spacing-xs) Space at the end of the scroll, so the last item’s border and focus ring are not clipped. The start stays flush. Set 0 to remove it

Tokens

It reads these shared tokens. A change to one also changes other components: see Tokens.

Source: the var() reads in _sass/components/_scroll-more.scss.

TokenPreviewValue
--divider-color
Read by --scroll-divider

var(--colors-alpha-black-10)
Dark mode var(--colors-alpha-white-10)

JavaScript

Method Effect
NDS.ScrollMore.init() Starts every .nds-scroll-more on the page that has not started yet
NDS.ScrollMore.create(wrapper) Starts one wrapper. It does nothing on a wrapper that has started
NDS.ScrollMore.refresh(wrapper) Checks the overflow again. Call it after you add or remove items while the wrapper keeps its size
NDS.ScrollMore.destroy(wrapper) Removes the listeners, the divider it built, data-axis and the overflow states. Call it before you remove the wrapper
var wrapper = document.querySelector('.nds-scroll-more'); wrapper.querySelector('.nds-scroll-more-content').insertAdjacentHTML('beforeend', '<li>Jazan</li>'); NDS.ScrollMore.refresh(wrapper);

The full API is in the banner of _js/nds-scroll-more.js.

Last Modified Date: 18/11/2026 - 12:35 PM
Was this page useful?
60% of users said Yes from 2843 Feedbacks