Skip to main content
Login

Sign in to access your account

Hero - National Design System

The banner at the top of a page, with the page title, or a slider of full-width images on the home page.

Overview

The hero is the first section in main. It comes in two forms. The sub hero is on most pages: a breadcrumb, the page title and a description, on a light tint of the brand primary. A service page and a profile page have their own shape of it. The main hero is on the home page: a Swiper of slides, each with a full-width image under a tint and its own title.

Pick another component when:

  • the title belongs to a section of the content, not to the page: Section
  • the page says that something was not found, sent or failed: Status Section
  • the slides are cards or images inside the content: Swiper

The hero is one region of the page. The other regions are on Page Layout.

Markup

Preview
<section class="nds-hero-section nds-sub"> <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><a href="#">About</a></li> <li class="nds-truncate" aria-current="page">About the Authority</li> </ol> </nav> <div class="nds-section-wrapper"> <div class="nds-section-head"> <div class="nds-section-action"> <div class="nds-share nds-dropmenu"> <button class="nds-btn nds-secondary-outline nds-dropmenu-trigger" aria-label="Share Page" data-i18n-aria-label="share.share_page"> <i class="nds-icon nds-hgi-share-01" aria-hidden="true"></i> <span class="nds-label" data-hidden="sm sr" data-i18n="share.share_page">Share Page</span> </button> <div class="nds-dropmenu-menu" hidden> <button class="nds-btn nds-subtle nds-dropmenu-item nds-share-x" type="button" aria-label="Share on X" data-i18n-aria-label="share.share_on_x"> <i class="nds-icon nds-hgi-new-twitter" aria-hidden="true"></i> <span class="nds-label">X</span> </button> <button class="nds-btn nds-subtle nds-dropmenu-item nds-share-linkedin" type="button" aria-label="Share on LinkedIn" data-i18n-aria-label="share.share_on_linkedin"> <i class="nds-icon nds-hgi-linkedin-02" aria-hidden="true"></i> <span class="nds-label">LinkedIn</span> </button> <button class="nds-btn nds-subtle nds-dropmenu-item nds-share-whatsapp" type="button" aria-label="Share on WhatsApp" data-i18n-aria-label="share.share_on_whatsapp"> <i class="nds-icon nds-hgi-whatsapp" aria-hidden="true"></i> <span class="nds-label">WhatsApp</span> </button> <button class="nds-btn nds-subtle nds-dropmenu-item nds-share-copy" type="button" aria-label="Copy Link" data-i18n-aria-label="share.copy_link" data-copy-label data-no-auto-close> <i class="nds-icon nds-hgi-link-04" aria-hidden="true"></i> <span class="nds-label" data-i18n="share.copy_link">Copy Link</span> </button> </div> </div> </div> <h1 class="nds-section-title">About the Authority</h1> <p class="nds-section-description">The Digital Government Authority leads digital transformation across Saudi government services.</p> </div> </div> </section>

Parts

The sub hero is a section with a breadcrumb before its wrapper. Its head parts are the parts of a Section head, in this order: the title action, the title, the brief, the tags, then the description.

Part Holds Required
section.nds-hero-section.nds-sub The sub hero Yes
nav.nds-breadcrumb-nav The Breadcrumb. The last item is the page, with nds-truncate and aria-current="page" Yes
.nds-section-wrapper The head, and the action row after it Yes
.nds-section-image A 120px Avatar before the head (80px on phones). For a page about one person or entity No
.nds-section-head The head parts, in the order above Yes
.nds-section-action in the head The title action: written first in the head, it floats on the end side of the title. With data-hidden="sm sr" on their labels, its buttons show only their icons on phones, so each one needs an icon. With nds-wrap, it moves under the title on phones No
h1.nds-section-title The page title. The sub hero holds the page’s h1 Yes
.nds-section-brief One short line under the title, in semibold No
.nds-section-meta Under the title: a .nds-section-tags of small Tags, a Meta line such as an article’s dates and author, or both No
.nds-section-description One or two sentences on the page Yes
.nds-section-action after the head The action row. It sits beside the head, on the end side, and moves under the description when the head has a title action No

The main hero is a section that holds one hero swiper. The navigation row is the Swiper’s.

Part Holds Required
section.nds-hero-section The main hero, with no nds-sub Yes
.nds-swiper.nds-hero The slides. Write nds-oncolor and nds-full-width with it Yes
.nds-swiper-slide.nds-content-wrapper One slide. Write hidden on every slide after the first Yes
.nds-hero-image-wrapper The image and its tint. --hero-overlay-opacity in its style sets the tint for the slide, and --hero-image-position the part of the image in view Yes
img.nds-hero-image The image, in a picture with one source for each screen size. Give it alt="": the image is decoration Yes
.nds-section-body The title, the description and a .nds-section-action with one or two buttons. The first slide’s title is the page’s h1, the others are h2 Yes

Behavior

Hero Slider

The main hero shows one slide at a time, and the Swiper script moves between them. Before the script starts, only the first slide shows, so the page paints with its image. The later slides load their images from data-src and data-srcset when they come near the screen. The slider options are on Swiper.

Background Image

--hero-image on the sub hero puts a photo behind it. The photo is solid at the end side and fades out toward the title, so the tint shows under the text. The fade turns with the text direction. The tint also covers half of the photo. Knobs in the API change the fade, the part in view and the tint. nds-flat hides the photo.

Built-in Features

  • First Paint

    The title, the description and the breadcrumb paint with the critical CSS, before the rest of the page. The buttons keep their height while they load, so nothing moves.

  • Height

    The main hero is 550px high on every screen, and each image covers it. --hero-height changes it. The sub hero is as high as its content, at least 220px.

  • Title Sizes

    The main hero's title is a large display size, and the sub hero's is one size smaller. Both scale with the screen width.

  • Brand Tint

    The tint over a slide image and the sub hero background come from theme tokens, so they follow a brand change.

Best Practices

  • Use the main hero on the home page and on the home page of a sub-site. Every other page uses the sub hero.
  • Keep the description to one or two sentences. The hero says where the reader is. The content comes after it.
  • Put one or two buttons in the action row. In the title action, put Share and at most one main button, such as the start of a service. Share is optional: leave it out on a page with no public link, such as a console.
  • Give the first slide’s image fetchpriority="high". It is the largest paint on the home page.
  • Preload the first slide’s image in the <head>, with one <link rel="preload" as="image"> for each source. Copy the media of each source exactly, or the browser loads one file and paints another. Each page preloads only its own hero image. See Head.
  • Give each later slide’s img a data-src, and each of its source elements a data-srcset. A plain srcset loads at once.
  • Keep a photo in the main hero. If the photo is not ready, point the picture at a placeholder image and replace it later.
  • Set --hero-overlay-opacity on each slide for its image: about 0.4 to 0.5 for a dark image, and 0.6 to 0.8 for a bright one.
  • Do not set --background-image-overlay. It follows the brand, and a fixed value stops that.
  • For a photo in the sub hero, pick one with its subject on one side. The fade keeps the end side and hides the side of the title.
  • Do not write nds-oncolor on text in a flat hero: it shows white on a light page.

API

Other Classes

Class Element Effect
nds-aside section.nds-hero-section.nds-sub At 960px and wider, narrows the breadcrumb, the title and the description by the width of the side info column. The column then moves up beside the title. Write it only on a page with a side info column: see Side Info

CSS Custom Properties

Property Default Controls
--hero-height 550px The height of the main hero. Set it in the style of the section
--hero-image None The photo of the sub hero, as url('…'). Set it in the style of the section
--hero-image-position 50% 50% on a slide, left center on the sub hero The part of the image that stays in view, such as 50% 30%. On the main hero, set it in the style of each .nds-hero-image-wrapper. On the sub hero, set it in the style of the section, with --hero-image
--hero-image-fade-angle 90deg, or 270deg on a left-to-right page The direction of the photo’s fade. Another angle fades it from the top or a corner
--hero-image-fade-from 0% Where the fade starts. Up to this point, the photo is solid
--hero-image-fade-to 70% Where the photo is gone
--hero-overlay-opacity 0.7 on a slide, 0.5 on the sub hero The strength of the tint over the image, from 0 (none) to 1 (solid). On the main hero, set it in the style of each .nds-hero-image-wrapper. On the sub hero, set it in the style of the section, with --hero-image
--hero-overlay-color var(--background-image-overlay) The color of the tint on a main hero slide, for one slide that needs another color. On the sub hero, the tint is the section’s own background
--background-image-overlay var(--colors-primary-950) The default tint color, a theme token. A custom brand sets it to var(--colors-neutral-950). Do not set it
--background-hero var(--background-primary-strong) The color behind the main hero, a theme token. It shows until the first image loads
--background-sub-hero var(--background-primary-light) The color of the sub hero, a theme token. High contrast mode changes it

JavaScript

The hero has no script of its own. The Swiper script runs the main hero, and the Share script runs the Share menu: see Swiper and Share.

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