Top Bar
A slim utility bar above the main navigation that holds the DGA digital stamp trigger, date and time widgets, and a dark mode toggle.
Top Bar Widgets
Three optional widgets for the top bar: date, clock, and city/weather. Each initializes automatically when its element IDs are on the page. DGA compliance permits a maximum of two: choose the combination that best serves your audience.
<!-- Hijri or Gregorian date (set via data-calendar) -->
<span id="nds-date" class="nds-text-icon" data-calendar="hijri"></span>
<!-- Real-time clock (updates every second) -->
<span id="nds-realTimeClock" class="nds-text-icon"></span>
<!-- City & Weather (both required, coordinates on weatherInfo) -->
<span id="nds-cityName" class="nds-text-icon"></span>
<span id="nds-weatherInfo" class="nds-text-icon"
data-latitude="24.7136" data-longitude="46.6753"></span>
Widget Reference
| Element ID | JS Module | Description |
|---|---|---|
#nds-date |
NDS.TimeDate |
Displays the current date. Set data-calendar="hijri" for the Islamic calendar or data-calendar="gregorian" for the Gregorian calendar. Fetches Hijri dates from the Aladhan API with a 24-hour local cache. Defaults to Hijri for Arabic pages and Gregorian for English. |
#nds-realTimeClock |
NDS.TimeDate |
Live clock that updates every second in 12-hour AM/PM format. |
#nds-cityName + #nds-weatherInfo |
NDS.CityWeather |
Displays the city name and current weather side by side. City is reverse-geocoded via the Nominatim API (30-day cache), weather is fetched from Open-Meteo (15-minute cache). Set data-latitude and data-longitude on #nds-weatherInfo to configure the location (defaults to Riyadh). Both elements must be present: they share coordinates and initialize together as a single widget. |
DGA Digital Stamp
An expandable panel triggered from the top bar that verifies the site as an official Saudi government digital property. Displays domain verification and HTTPS security notices alongside the DGA registration number.
Built-in Features
Widgets, the DGA stamp toggle, and the theme switch all activate as soon as their elements are on the page. No manual wiring required.
The top bar button expands and collapses the digital stamp panel with animated grid-row transitions, automatically closing any open nav menus first.
Date refreshes every 24 hours, the real-time clock ticks every second, and both switch language with the page to keep the surface aligned with user locale.
The date widget supports both calendars via data-calendar. Hijri values come from the Aladhan API with a browser Intl fallback when offline.
Reverse-geocoded city name pairs with live weather readings from Open-Meteo. Coordinates are configurable per page via data attributes.
Hijri dates cache for 24 hours, weather for 15 minutes, and city names for 30 days, reducing API calls and keeping the top bar responsive across page loads.
Usage Guidelines
Best Practices
- Include the DGA digital stamp on all government websites. The top bar trigger and hidden panel are mandatory for DGA compliance. Populate the registration number and notice text from site configuration.
- DGA compliance allows a maximum of two top bar widgets. Choose any two from: date, clock, or city/weather.
- Pair the clock with the date when the service is time-sensitive (appointments, deadlines, submissions). Pair the date with city/weather on portals where users need general awareness (citizen services, public dashboards).
- Set
data-calendar="hijri"on the date widget for Arabic audiences and Saudi government properties. Leave it at the default for English-only international-facing services. - Always set explicit
data-latitudeanddata-longitudeon the weather widget. Do not rely on the Riyadh default for services that target a specific city or region. - Do not remove the theme toggle. Dark mode is part of the NDS accessibility baseline.
- Do not add custom buttons to the top bar. Utility actions belong in the navigation bar's secondary actions area, which persists across all breakpoints.
- Keep the
nds-digitalStamp-lg-textverification copy short. Long text truncates on tablet before switching to thends-digitalStamp-sm-textfallback.
Modifier Classes
| Class | Element | Description |
|---|---|---|
nds-digitalStamp-tab | top bar button | Styles the DGA stamp trigger with flag icon and verification text |
nds-digitalStamp-lg-text | inside stamp tab | Full-length label shown on desktop, hidden on tablet and below |
nds-digitalStamp-sm-text | inside stamp tab | Short label shown on tablet and below, hidden on desktop |
nds-topbar-info | container | Groups the DGA tab contents and the right-side widget cluster |
Data Attributes
| Attribute | Element | Description |
|---|---|---|
data-theme-toggle | top bar button | Registers the element as a dark/light mode toggle |
data-calendar | #nds-date | Set to hijri or gregorian. Defaults to Hijri for Arabic pages. |
data-latitude / data-longitude | #nds-weatherInfo | GPS coordinates for weather and city lookup. Defaults to Riyadh (24.7136, 46.6753). |
JavaScript API
The top bar widgets initialize automatically when their element IDs exist on the page. Use these APIs to re-initialize after dynamic content changes, refresh individual widgets manually, or pull Hijri dates programmatically for use elsewhere.