Header Structure
The header wraps three layers: the top bar for government branding and utilities, the main navigation bar, and the expandable DGA digital stamp panel.
Built-in Features
Activates when .nds-main-nav is on the page. Dropdowns, collapse, overflow detection, and scroll behavior attach automatically.
Switches from a horizontal nav bar to a hamburger menu at a configurable breakpoint, with animated expand and collapse transitions.
Primary nav items that exceed the available width become scrollable, with a show-more button that scrolls through hidden items.
Dropdown content can be organized in column, row, or multi-column list layouts that adapt to narrower screens.
Same-page anchor links in the nav close open menus and scroll smoothly to the target section.
Primary nav supports horizontal drag scrolling and converts vertical mouse wheel input to horizontal scroll when items overflow.
Scroll direction, drag behavior, and layout flip automatically in right-to-left contexts.
All header transitions respect the prefers-reduced-motion setting, skipping animations for users who have requested it.
Nav items marked with nds-PAB automatically relocate to the minimal nav bar on small screens and return to their original position on larger viewports.
Opening a dropdown or the mobile collapse displays a backdrop that closes the menu on outside clicks, preventing interaction with page content beneath.
Usage Guidelines
Best Practices
- Place the header at the top of every page. The top bar sits above the navigation bar, and both are rendered inside a
<header>element. - Keep primary nav items between 3 and 8 links. Overflow handling activates automatically, but excessive items reduce usability.
- Use dropdown menus for grouping related pages under a single primary nav item. Organize content into columns using
nds-colViewfor category-based layouts ornds-rowViewfor flat lists. - Reserve the secondary nav for utility actions: search, language toggle, user profile, notifications. These persist across all breakpoints as icon-only buttons on smaller screens.
- Use
nds-CTAon a nav item to visually highlight a primary call-to-action button in the navigation bar. - Do not use the main navigation for in-page section links. Use Tabs for switching between content panels on the same page, or anchor links within the page body.
- Do not place critical actions only inside dropdown menus. Users on mobile may not discover them. Promote key actions to the primary or secondary nav level.
- Do not add more than one level of dropdown nesting. The component supports single-level dropdowns only.
- Set the brand logo dimensions explicitly with
widthandheightattributes to prevent layout shift during page load. - Use
nds-icon-onlyon secondary nav items that should display as icon buttons. Labels are automatically hidden on smaller screens for non-CTA items. - Mark nav items that must remain visible at all breakpoints with
nds-PAB. These items automatically move to the minimal nav bar on small screens and return to their original position on wider viewports.
Modifier Classes
| Class | Element | Description |
|---|---|---|
nds-dropdown | nav-item | Enables dropdown menu behavior |
nds-CTA | nav-item | Styles the item as a call-to-action button |
nds-icon-only | nav-item | Displays as icon button, hides label |
nds-PAB | nav-item | Persistent action button that relocates to the minimal nav bar on small screens |
nds-show-more | nav-item | Marks the overflow scroll button |
nds-oncolor | nav-link | Applies on-color text styling for dark backgrounds |
nds-menu-btn | nav-link | Transparent background style with indicator for primary nav items (mobile) |
nds-fit | dropdown-menu | Sizes the dropdown to fit its content width |
nds-colView | dropdown-columns | Organizes content in vertical columns |
nds-rowView | dropdown-columns | Organizes content in a horizontal row layout |
nds-multi-column-list | list inside dropdown | Renders items in a 3-column grid |
Data Attributes
| Attribute | Element | Description |
|---|---|---|
data-state="current" | nav-link | Marks the active page in the navigation |
CSS Custom Properties
| Property | Default | Description |
|---|---|---|
--nds-nav-height | 72px | Height of the navigation bar |
--nds-minimal-nav-bp | 960px | Breakpoint width for switching to mobile/minimal mode |
--nds-transition-speed | 0.2 | Base transition speed in seconds |
--nds-minimal-nav-item-height | 40px | Height of each nav item in the mobile collapse panel |
JavaScript API
The header initializes automatically when .nds-main-nav exists on the page. It is priority 1 in the loader (first to initialize). Toggle functions are exposed globally on window for use in HTML onclick attributes.