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:
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
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 |
Variants
Each shape is the markup of a live page, listed in the Overview. Side menu and Side info go on a standard page only. Side info writes three changes: the hero class, the content layout class, and the side info section as the first section.
| Group | Option | Markup | On element | Use |
|---|---|---|---|---|
| Structure | Standard page (default) (id: standard) | — | — | A service, information or documentation page: the sub hero first in main, then the content layout, then the page feedback |
| Structure | Home (id: home) (demo: + stripe) | canon #layout-home |
— | The home page: the hero slider first in main. Write Stripe too: the home page stripes its sections. No page feedback |
| Structure | Article (id: article) | canon #layout-article |
— | A guide or a long text page: a flat hero, then one section that holds the text and a table of contents beside it |
| Structure | Minimal (id: minimal) | canon #layout-minimal |
— | Sign in, a one-time code and other focused steps. No header, hero or footer. The content centers in the screen, over an optional page image |
| Structure | Console (id: console) | canon #layout-console |
— | An admin or back-office page. nds-full-width on the content layout takes the page to the screen edges, and the hero sits in nds-content beside the side menu |
| Side column | None (default) | — | — | No side column |
| Side column | Side menu (not: home, article, minimal, console) | .nds-has-sidemenu |
.nds-content-layout |
A menu of the pages in this part of the site, beside the content on a desktop |
| Side column | Side menu (not: home, article, minimal, console) | canon #layout-sidemenu |
.nds-content-layout (start) |
The side menu aside. Written with nds-has-sidemenu |
| Side column | Side info (not: home, article, minimal, console) (hint: Facts beside the first section’s text) | .nds-has-sideinfo |
.nds-content-layout |
A service page: facts such as the fee and the duration beside the first section’s text |
| Side column | Side info (not: home, article, minimal, console) (hint: Facts beside the first section’s text) | .nds-aside |
.nds-hero-section.nds-sub |
Narrows the hero title, so the side info moves up beside it on a desktop. Written with nds-has-sideinfo |
| Side column | Side info (not: home, article, minimal, console) (hint: Facts beside the first section’s text) | canon #layout-sideinfo |
.nds-content (start) |
The first section, which holds the text and the side info. Write the service description in it, not in a second section. Written with nds-has-sideinfo |
| Hero | Flat hero (not: article, minimal, home) (hint: No background or shadow, so the text starts right under the title) | .nds-flat |
.nds-hero-section.nds-sub |
A page with long text. The hero loses its background and shadow |
| Card view | Card view (not: home, article, minimal) (hint: Each section shows as a raised card) | .nds-card-view |
.nds-content-layout:not(.nds-compact) |
Each section shows as a raised card, for record and profile pages. Not with Compact |
| Compact | Compact (not: home, minimal) (hint: The side menu and the sections are raised on the page background) | .nds-compact |
.nds-content-layout:not(.nds-card-view) |
The raised look on a desktop: the sections get a shadow too, and the side menu and the sections sit on the page background and keep their side padding. Not with Card view |
| Full width | Full width (not: minimal, console) (hint: The page reaches the screen edges) | .nds-full-width |
.nds-content-layout |
The header, the content and the footer reach the screen edges, for an admin page or a wide table |
| Stripe | Stripe (id: stripe) (not: article, minimal) | .nds-stripe |
.nds-content:not(.nds-card-view .nds-content) |
Every second section gets the stripe color, from the second one |
| Odd | Odd (hint: The stripe starts on the first section) | .nds-odd |
.nds-content.nds-stripe:not(.nds-card-view .nds-content) |
The stripe starts on the first section. Needs Stripe |
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-widthand centers, with the same gutter as the header and the footer. -
Footer at the Bottom
bodyis a column, andmainand 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
mainclips its overflow and does not scroll it. A sticky side menu or tab bar sticks to the screen, not tomain. -
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 betweenbodyandmainthat stopsmainfrom 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-layoutper 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
bodycovers only the first page. A link from a minimal page, such as a sign-in withnds-page-bg, to a full page otherwise keeps the old class. - Give a framework’s mount element between
bodyandmain(#root,#app,app-root)display: contents. If the app styles that element, give itflex: 1; display: flex; flex-direction: columninstead. Without one of them,maindoes not grow, and the footer moves up the screen. Write it where the first paint sees it: astyleattribute on the element, or a stylesheet that loads before the body. A stylesheet withdata-nds-deferdoes 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 innds-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. Innds-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 withnds-aside, which moves the side info up beside the title. - In an app with a hash router (
#/page), the skip link’s#main-contentreads as a route. Handle its click instead:preventDefault(), then focus#main-content, which needstabindex="-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
Front Matter
For AI agents. The .md source of a live page holds only its content. Its front matter names the layout that builds the rest of the body, and this table maps each key to its markup.
| Key | Value | Markup |
|---|---|---|
layout |
page |
A standard page: the sub hero first in main, then the content layout with a side menu, then the page feedback |
layout |
home |
The home page: the hero slider, then the content layout with nds-stripe on nds-content |
layout |
console |
A console: the content layout with a side menu, the sub hero first in nds-content, then the page feedback. The page also sets layout_class: nds-full-width |
layout |
minimal |
A minimal page: no header, hero or footer, and nds-content-wrapper on the content layout |
layout |
shell |
The page writes its whole body itself, as the Home Page Template does |
layout_class |
Classes | Added to .nds-content-layout: nds-has-sideinfo, nds-card-view, nds-compact, nds-full-width, nds-middle |
body_class |
Classes | Added to body |
content_class |
Classes | Added to .nds-content on a page layout: nds-stripe, nds-odd |
sidemenu_mode |
false |
No side menu, and no nds-has-sidemenu |
sidemenu_mode |
top |
nds-top on the side menu aside |
hero_style |
Classes | Added to the sub hero section: nds-flat, nds-aside |
page_bg |
Image path | On a minimal page: nds-page-bg on body, with the image in --bg-img |
bg_opacity_top, bg_opacity_bottom |
Percent | On a minimal page: --bg-opacity-top and --bg-opacity-bottom on body. Default 80% |
last_edit |
Date | The last modified section, last in nds-content. page layout only |
hideFeedback |
true |
No page feedback section |
feedback_type |
rating |
The star rating strip in place of the Yes and No feedback |
The hero’s own keys (hero_title, hero_description, breadcrumb and more) are on the Hero page.
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.