Skip to main content
Login

Sign in to access your account

Clock - National Design System

The current time, in the site's timezone, that changes on the minute.

Overview

A <time class="nds-clock"> shows the current time as h:mm AM. The script writes it, and writes it again at each new minute. A page can show any number of clocks. The Top Bar can show one as an item.

The script writes the time only. The icon and the look are yours: the canon uses a Meta line.

Pick another component when:

  • the page shows today’s date: Date
  • the page counts down to a moment: Countdown

Markup

Preview
<span class="nds-meta"> <span class="nds-meta-item"><i class="nds-icon nds-hgi-clock-01" aria-hidden="true"></i><time class="nds-clock"></time></span> </span>

Built-in Features

  • One Timer

    One timer serves every clock on the page, at the turn of each minute. It stops while the tab is hidden, and the clocks catch up when it shows again.

  • Site Timezone

    The clock shows the time in the timezone that data-timezone on <html> names, or the visitor's time without it.

  • No Work When Hidden

    A clock that data-hidden hides at the current width is not written. When no clock shows, the timer stops.

Best Practices

  • Show a clock for a time-bound service: appointments, deadlines, submissions. Leave it out where the time does not matter.
  • Set data-timezone on <html> when every visitor must see the service’s time, such as Riyadh time for a deadline.
  • Write the <time> empty. The script writes the time after the page shows, so the clock is empty until then.
  • In the top bar, the clock is one of the two items DGA allows.

API

Classes

Class Element Effect
.nds-clock <time> The clock. The script writes its text, such as 2:05 PM, and its datetime, such as 14:05

Data Attributes

Attribute Element Effect
data-timezone <html> The site’s timezone, as an IANA name such as Asia/Riyadh. See Date
data-hidden The clock, or an element around it Hides it in the named width bands. See Hidden

JavaScript

NDS.Clock loads after the page shows. Until it loads, a call to it loads it and returns a promise.

Method Effect
NDS.Clock.init() Writes every clock on the page and starts the minute timer. The loader runs it when a clock is on the page, and NDS.init.mount() on markup added later

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

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