Skip to main content
Login

Sign in to access your account

Page Layout - National Design System

The body structure every NDS page is built on, from the header to the footer, and the classes that pick the page shape

Overview

Every NDS page has one body structure. A skip link comes first, then the header, main and the footer. main holds the hero and one nds-content-layout. The content layout holds an optional side menu and nds-content, and nds-content holds the page sections. Classes on body, on the content layout and on the main content pick the page shape.

Each shape in the builder below is the markup of a live page. Open the page to see the whole shape at work. Chrome is the frame around the content: full has the header and the footer, minimal has neither, and console reaches the screen edges:

Shape Use Chrome Live page
Standard page A service, information or documentation page full Services List
Standard page + Side info A service page, with its facts beside the first section full Service Template
Home The home page full Home Page Template
Article A guide or a long text, with a table of contents full Get Started
Minimal Sign in and other focused steps minimal Sign In
Console An admin or back-office page console Console

Pick another page when:

  • you build the content of one section: Section
  • you place columns inside a section: Grid

The <head> and the markup of the header, hero, side menu and footer are on their own pages: Head, Header, Hero, Side Menu and Footer.

Markup

Preview
<body> <a class="nds-skip-link" href="#main-content">Skip to main content</a> <header> <!-- The header: copy it from ../ui-shell/header --> </header> <main> <section class="nds-hero-section nds-sub"> <!-- Share and the other forms of the sub hero: ../ui-shell/hero --> <nav class="nds-breadcrumb-nav" aria-label="Breadcrumb" data-i18n-aria-label="breadcrumb.breadcrumb"> <ol class="nds-breadcrumb"> <li><a href="#">Home</a></li> <li class="nds-truncate" aria-current="page">Hero Section</li> </ol> </nav> <div class="nds-section-wrapper"> <div class="nds-section-head"> <h1 class="nds-section-title">Hero Section</h1> <p class="nds-section-description">One or two sentences on what the page holds.</p> </div> </div> </section> <div class="nds-content-layout"> <div class="nds-content" id="main-content"> <section class="nds-content-section"> <div class="nds-section-wrapper"> <div class="nds-section-head"> <h2 class="nds-section-title">Renew a Passport</h2> <p class="nds-section-description">Renew your passport online through Absher. The new passport is ready within 3 working days.</p> </div> </div> </section> <section class="nds-content-section"> <div class="nds-section-wrapper"> <div class="nds-section-head"> <h2 class="nds-section-title">Required Documents</h2> <p class="nds-section-description">Bring the old passport and your national ID when you pick up the new passport.</p> </div> </div> </section> <section class="nds-content-section"> <div class="nds-section-wrapper"> <div class="nds-section-head"> <h2 class="nds-section-title">Fees</h2> <p class="nds-section-description">The fee is 300 riyals for 5 years, or 600 riyals for 10 years.</p> </div> </div> </section> <section class="nds-last-edit nds-content-section"> Last Modified Date: 12/08/2026 - 10:30 AM </section> </div> </div> <section class="nds-user-feedback-section nds-content-section"> <!-- The page feedback: ../components/user-feedback --> </section> </main> <footer class="nds-footer nds-content-wrapper" data-theme="dark oncolor primary" role="contentinfo" aria-label="Site Footer" data-i18n-aria-label="footer.site_footer"> <!-- The footer: copy it from ../ui-shell/footer --> </footer> <!-- After the footer: the accessibility FAB, see ../ui-shell/accessibility --> <!-- Last in body: the nds-main.min.js script tag, see ../ui-shell/head --> </body>

Parts

Part Holds Required
body The skip link, the header, main and the footer, in a column. nds-page-bg puts an image behind a minimal page Yes
a.nds-skip-link The first child of body: a link to #main-content, hidden until it has focus. The label is “Skip to main content”, or “تخطي إلى المحتوى الرئيسي” on an Arabic page Yes
header The top bar and the main navigation: Header. A minimal page has none No
main The hero, the content layout, and the page feedback after it Yes
section.nds-hero-section The page hero: Hero. A standard page uses the sub hero (nds-sub), and the home page the hero slider. An article adds nds-flat, and a service page with side info adds nds-aside. A console puts the hero in nds-content No
.nds-content-layout The side menu, if any, and nds-content. The shape classes go on it Yes
aside.nds-sidemenu The side menu, as the first child: Side Menu. It needs nds-has-sidemenu on the content layout No
.nds-content The page sections, with id="main-content" for the skip link. The stripe classes go on it Yes
section.nds-content-section One page section: Section Yes
section.nds-last-edit.nds-content-section The last modified date, as the last section of nds-content No
section.nds-user-feedback-section The page feedback, in main after the content layout: User Feedback No
footer.nds-footer The footer: Footer. A minimal page has none No

Behavior

Side Menu

nds-has-sidemenu on the content layout makes two columns at 960px and wider: the side menu, then the content. The menu column is --nds-sidemenu-width wide. Below 960px the layout has one column, and the side menu shows as a compact control. nds-top on the aside shows the menu as a bar above the content: see Side Menu. Without nds-has-sidemenu or nds-has-sideinfo, the layout hides an aside that is its direct child.

On a desktop, a side menu page is one surface: the content layout has the --background-default color, and only the side menu has a --shadow-md shadow. The menu keeps its side padding. A --nds-viewport-padding gap splits the menu from the content, so the sections have no side padding. A section with its own fill keeps its side padding: a primary or neutral word in data-theme, the deprecated classes nds-primary, nds-gradient-primary, nds-neutral and nds-brand. Every section of a striped nds-content keeps it too. A full-width page has no page gutter, so its sections keep their side padding and the layout has no gap.

Side Info

Side info is not a layout column. Its aside sits in a nds-sideinfo-section, beside the text it describes. nds-has-sideinfo on the content layout adds no column: it tells the layout that the page has a side column, so the larger section padding of a page without one does not apply. On a service page the side info section is the first section, and nds-aside on the sub hero narrows the hero title on a desktop. The side info then moves up beside the title. The aside markup is on the Side Info page.

Article

An article is one side info section that holds the whole text. The aside holds a table of contents, which nds-toc builds from the headings of the article: see Table of Contents. The hero is flat (nds-flat), with no background or shadow, so the text starts right under the title.

Card View

nds-card-view shows each section as a raised card at the content width, with smaller section titles and a gap between the cards. The hero and a section with nds-ghost stay flat. Card view never stripes, and it keeps its gutters on a console page.

Compact

nds-compact on the content layout gives a desktop page the raised look. The sections get a --shadow-md shadow like the side menu, on the --background-body color, and the sections keep their side padding. On a page with no side menu, only the sections get the shadow. Phones and tablets look the same with or without it.

Section Stripes

nds-stripe on nds-content gives every second section the --background-stripe color, from the second section. Add nds-odd too, and the stripe starts on the first section instead, for a first section that must stand apart from the hero. The stripes work at every screen width, with or without a side menu. The count includes every section in nds-content, so a section that is added or removed flips the color of every section below it. On a console, the hero is the first section in the count.

A section that paints its own background is never striped, but it still counts: a primary or neutral word in data-theme, the deprecated classes nds-primary, nds-gradient-primary, nds-neutral and nds-brand, and nds-user-feedback-section. The last modified section always takes the color of the section above it.

Console

A console is a full-width page with a side menu. The hero is in nds-content, beside the side menu.

A console has no side info, because the side menu holds the side column. What a standard page shows in side info goes at the top of the first section instead. For the Form Template, that is the stepper above the form: leave out nds-vertical so the steps sit in a row, and keep nds-radial-sm for phones.

Full Width

nds-full-width on the content layout sets --nds-content-max-width to 100%, so the content reaches the screen edges. The content layout also removes its own gutters, except in card view. The header and the footer follow it through :has(). A browser without :has() keeps them at the content width, and the content still reaches the edges.

Minimal Page

nds-middle makes the content layout at least as tall as the screen, and centers the content in it. nds-content-wrapper adds the page gutter on every side. nds-page-bg on body shows --bg-img behind the page, under a layer of the page background color.

Built-in Features

  • Centered Content Width

    The content stops at --nds-content-max-width and centers, with the same gutter as the header and the footer.

  • Footer at the Bottom

    body is a column, and main and the content layout grow into the space left. On a short page, the footer stays at the bottom of the screen.

  • Skip Link

    The first Tab on a page shows a link to nds-content, so a keyboard user skips the header, the hero and the side menu. The link is hidden until it has focus, from the first paint, and the content lands below the sticky main navigation.

  • Sticky Parts

    main clips its overflow and does not scroll it. A sticky side menu or tab bar sticks to the screen, not to main.

  • Minimum Content Height

    The content layout is at least 400px tall, and the sections grow to fill the space left.

  • Section Padding by Shape

    On a desktop, a page with no side column gives its sections 64px of padding above and below.

  • Layout Audit

    NDS.init.audit() warns about an element between body and main that stops main from growing, and about an extra child of the content layout.

  • CSS Only

    The layout needs no script. The side menu's behavior comes from Side Menu.

Best Practices

  • Fill the empty header and footer of a shape from the Header and Footer pages, and take the script tags from the Head page. Never ship a shape with its header or footer left empty.
  • Keep each shape’s classes as its live page has them. A structure written from memory loses the classes that set the width, the centering and the background.
  • Use one nds-content-layout per page. Never put one content layout in another.
  • Put every page section in nds-content.
  • Write the layout classes in the HTML that the browser paints first. A class that a script adds after the app starts shows one frame at the wrong shape.
  • In an app whose layout class depends on the route, set the class with a script that runs at once, as the first child of body, before the framework starts. A mount effect runs too late.
  • In a single-page app, set the class again on each route change, such as from the router’s after-navigation hook. The script in body covers only the first page. A link from a minimal page, such as a sign-in with nds-page-bg, to a full page otherwise keeps the old class.
  • Give a framework’s mount element between body and main (#root, #app, app-root) display: contents. If the app styles that element, give it flex: 1; display: flex; flex-direction: column instead. Without one of them, main does not grow, and the footer moves up the screen. Write it where the first paint sees it: a style attribute on the element, or a stylesheet that loads before the body. A stylesheet with data-nds-defer does not hold the first paint. Under a strict Content Security Policy, use the stylesheet.
  • Return a fragment, not a wrapper div, from a framework component in the content layout or in nds-content. In the content layout, a wrapper takes a grid column: with a side menu, the whole page shrinks to the side menu’s width. In nds-content, a wrapper gets no width of its own, so narrow content moves away from the page edges.
  • Angular has no fragments: it keeps each component’s tag in the page. Give a component that renders an NDS element an attribute selector, such as selector: 'section[appSubHero]', so its tag is the NDS element. A tag in between breaks the NDS rules that read the next element, such as the hero with nds-aside, which moves the side info up beside the title.
  • In an app with a hash router (#/page), the skip link’s #main-content reads as a route. Handle its click instead: preventDefault(), then focus #main-content, which needs tabindex="-1" for that.
  • In an app with <base href>, such as Angular, a # link reads against the base, not the page: the skip link opens the home page. Handle its click the same way.
  • On a page with long text, flatten the hero with nds-flat: see Hero.

API

Other Classes

Class Element Effect
nds-post .nds-content-layout Removes the top padding of the first section

CSS Custom Properties

Set the first five on .nds-content-layout, and the last three on body.

Property Default Controls
--layout-min-height 400px The content layout’s minimum height. nds-middle sets 100dvh
--layout-gap 0 The gap between the side menu and the content. On a desktop, a side menu page sets --nds-viewport-padding, except at full width. Card view sets --spacing-xl. Always 0 on a phone
--content-padding-block 0 The padding above and below nds-content. Card view sets --spacing-xl below 960px
--content-padding-inline 0 The padding at the sides of nds-content
--content-gap 0 The gap between the sections. Card view sets --spacing-4xl
--bg-img Not set The image behind a body.nds-page-bg, as a url()
--bg-opacity-top 80% How strongly the page background color covers the image at the top of the page
--bg-opacity-bottom 80% How strongly the page background color covers the image at the bottom of the page

These tokens are global. Set them on :root.

Property Default Controls
--nds-content-max-width 1280px The width of the content, the header and the footer. nds-full-width sets 100%
--nds-sidemenu-width 260px The width of the side menu column
--background-stripe Theme token The color of a striped section

JavaScript

The page layout has no script, methods or events.

Last Modified Date: 20/11/2026 - 08:48 PM
Was this page useful?
60% of users said Yes from 2843 Feedbacks