Skip to main content
Login

Sign in to access your account

Empty - National Design System

Empty shows an icon and a short message in a container that has no items

Overview

Add nds-empty to a container that can have no items, such as search results, a filtered list or a notification list. It works on a <div>, a list, a table and a table body. An item is any child element. The script adds the placeholder while the container has no items, and removes it when one arrives. You write only the class.

Pick another component when:

  • the data is still loading: Loading.
  • a request failed and the rest of the view still shows: Alert, with data-status="error", so the user knows that something went wrong.
  • a request failed and the view has nothing else to show, or the page is a status, such as not found or no permission: Status Section. An empty cart or an empty list stays Empty, even when it is all the page shows: items can arrive without a reload.
  • the container has items but none match the user’s filter: Filter shows its own alert. A filtered-out item stays in the container, so the placeholder does not show.

Markup

Preview
<div class="nds-empty"></div>

Behavior

Live Updates

Add and remove items to watch the placeholder.

    Tables

    In a table, the placeholder is one row with one cell across every column. The script counts the columns in the header row. Only rows in a <tbody> count as content: the <thead>, <tfoot> and <caption> do not. When the column count changes, call NDS.Empty.refresh() on the element that carries nds-empty, and the cell spans the new count.

    Built-in Features

    • Automatic Setup

      Every nds-empty container with no items gets a placeholder, also a container added to the page later. You call nothing.

    • Markup That Fits the Container

      The placeholder is an <li> in a list, a row in a table and a <div> elsewhere. In an nds-grid container, it spans every column.

    • Arabic and English Text

      The default message follows the page lang: «لا يوجد محتوى» in Arabic, and "No content to show" in any other language.

    • Live Updates

      The placeholder goes away when an item is added, and comes back when the last item is removed. A new data-empty-message or data-empty-icon value shows at once.

    • No Flash at Load

      The container stays hidden until the placeholder is in. The page never shows it empty first.

    Best Practices

    • Show Loading while data loads, not the placeholder. If the request returns no items, the placeholder then shows.
    • Write a data-empty-message that says why the container has no items, or what the user can do next. “No requests match your search” tells the user more than “Empty”.
    • Keep the message to one short sentence. For a button under it, such as “Add a request”, put it in a <template data-empty-action> in the container. Put longer help outside the container.
    • Wrap text content in an element. The script counts child elements only, so a container that holds only text still shows the placeholder.
    • Do not add your own “no results” markup to the container. The script counts it as an item, so the placeholder never shows.
    • When your code counts the items in a container, skip the element with data-nds-empty-placeholder and the action’s <template>.

    API

    Other Classes

    Class Element Effect
    nds-empty-placeholder the placeholder <div> or <li> Set by the script. Style the placeholder through this class
    nds-empty-message the message <span> in the placeholder Set by the script. Style the message through this class

    Data Attributes

    Attribute Element Effect
    data-empty-message .nds-empty Replaces the default text. A change at run time updates the placeholder
    data-empty-icon .nds-empty Replaces the default icon, nds-icon nds-hgi-desert. The value becomes the whole class of the icon <i>. A change at run time updates the placeholder
    data-empty-action a <template> in .nds-empty Its content goes under the message in each placeholder, such as a button. The template is never an item
    data-nds-empty-placeholder the placeholder Set by the script on the placeholder element, and on a <tbody> it adds. Do not set it yourself

    Autocomplete reads the same two attributes for its no-results message.

    Tokens

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

    Source: the var() reads in _sass/components/_empty.scss.

    TokenPreviewValue
    --text-primary-paragraph
    Read by color

    var(--colors-neutral-700)
    Dark mode var(--colors-neutral-300)
    --text-secondary-paragraph
    Read by color

    var(--colors-neutral-500)
    Dark mode var(--colors-neutral-400)

    JavaScript

    Method Effect
    NDS.Empty.init() Fills every empty container and starts to watch the page. The loader calls it once. A second call does nothing
    NDS.Empty.refresh(el) Checks one .nds-empty element again: adds or removes its placeholder, and updates the column count of a table placeholder

    Empty fires no events. Call refresh() only for a change the script cannot see, such as a class added to an element already on the page.

    // Turn an element already on the page into an Empty container var results = document.querySelector('#results'); results.classList.add('nds-empty'); NDS.Empty.refresh(results); // Update the placeholder row after the table columns change NDS.Empty.refresh(document.querySelector('#requests-table'));

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

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