Navigation menu Overview

The navigation menu component provides a horizontal or vertical navigation system for web applications. It supports both simple navigation links and complex dropdown content areas, making it ideal for main navigation bars, and mega menu implementations.

When to Use

Use navigation menu components when:

  • Creating main site navigation bars
  • Implementing mega menus with rich content
  • Organizing hierarchical navigation structures

Don't use navigation menu components for:

  • Simple action menus (use command components)
  • Form selection dropdowns (use select or combobox)
  • Contextual actions on content (use command components)
  • Breadcrumb navigation (use breadcrumb component)
Examples Basic Horizontal Navigation

A simple horizontal navigation bar with active state management and clean styling.

<dap-ds-navigation-menu activeHref="/about">
<dap-ds-navigation-menu-item baseHref="/">
  <dap-ds-button slot="trigger" href="/" variant="subtle-menu" >
    <dap-ds-stack direction="row">
      <dap-ds-icon name="home-6-line"></dap-ds-icon>
      Home
    </dap-ds-stack>
  </dap-ds-button>
</dap-ds-navigation-menu-item>

<dap-ds-navigation-menu-item>
  <dap-ds-button slot="trigger" href="/about" variant="subtle-menu" >
    About
  </dap-ds-button>
</dap-ds-navigation-menu-item>

<dap-ds-navigation-menu-item>
  <dap-ds-button slot="trigger" href="/services" variant="subtle-menu" >
    Services
  </dap-ds-button>
</dap-ds-navigation-menu-item>

<dap-ds-navigation-menu-item>
  <dap-ds-button slot="trigger" href="/contact" variant="subtle-menu" >
    Contact
  </dap-ds-button>
</dap-ds-navigation-menu-item>
</dap-ds-navigation-menu>
Navigation with Dropdown Content

Navigation items can contain rich dropdown content for complex menu structures.

<dap-ds-navigation-menu activeHref="/products">
<dap-ds-navigation-menu-item>
  <dap-ds-button slot="trigger" href="/" variant="subtle-menu">
    <dap-ds-stack direction="row">
      <dap-ds-icon name="home-6-line"></dap-ds-icon>
      Home
    </dap-ds-stack>
  </dap-ds-button>
</dap-ds-navigation-menu-item>

<dap-ds-navigation-menu-item baseHref="/products">
  <span slot="title">Products</span>
  
  <dap-ds-stack spacing="100">
    <dap-ds-button href="/web-dev" variant="subtle-menu-item">
      <dap-ds-stack spacing="0">
        <dap-ds-stack direction="row">
          <dap-ds-icon name="tools-line"></dap-ds-icon>
          Web Development
        </dap-ds-stack>
        <dap-ds-typography variant="description">
          Build modern web applications
        </dap-ds-typography>
      </dap-ds-stack>
    </dap-ds-button>

    <dap-ds-button href="/mobile" variant="subtle-menu-item">
      <dap-ds-stack spacing="0">
        <dap-ds-stack direction="row">
          <dap-ds-icon name="cookie-line"></dap-ds-icon>
          Mobile Apps
        </dap-ds-stack>
        <dap-ds-typography variant="description">
          iOS and Android development
        </dap-ds-typography>
      </dap-ds-stack>
    </dap-ds-button>
  </dap-ds-stack>
</dap-ds-navigation-menu-item>

<dap-ds-navigation-menu-item>
  <dap-ds-button slot="trigger" href="/about" variant="subtle-menu" >
    About
  </dap-ds-button>
</dap-ds-navigation-menu-item>
</dap-ds-navigation-menu>
Mega Menu Layout

Create complex mega menus with grid layouts and organized content sections.

<dap-ds-navigation-menu fullWidth>
<dap-ds-navigation-menu-item>
  <dap-ds-button slot="trigger" href="/" variant="subtle-menu" >
    Home
  </dap-ds-button>
</dap-ds-navigation-menu-item>

<dap-ds-navigation-menu-item>
  <span slot="title">Services</span>
  
  <div style={{display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 'var(--dds-spacing-200)', padding: 'var(--dds-spacing-200)', minWidth: '400px'}}>
    <div>
      <dap-ds-typography variant="h4">
        Development
      </dap-ds-typography>
      <dap-ds-button href="/web-dev" variant="subtle-menu" >
        <dap-ds-icon name="design-tools-line"></dap-ds-icon>
        Web Development
      </dap-ds-button>
      <p style={{margin: 'var(--dds-spacing-200) 0 0 0', fontSize: 'var(--dds-font-size-sm)', color: 'var(--dds-color-text-secondary)'}}>
        Modern web applications
      </p>
      
      <dap-ds-button href="/mobile" variant="subtle-menu" >
        <dap-ds-icon name="device-computer-line"></dap-ds-icon>
        Mobile Development
      </dap-ds-button>
      <p style={{margin: 'var(--dds-spacing-200) 0 0 0', fontSize: 'var(--dds-font-size-sm)', color: 'var(--dds-color-text-secondary)'}}>
        iOS and Android apps
      </p>
    </div>
    <div>
      <dap-ds-typography variant="h4">
        Consulting
      </dap-ds-typography>
      <dap-ds-button href="/strategy" variant="subtle-menu" >
        <dap-ds-stack direction="row">
          <dap-ds-icon name="lightbulb-fill"></dap-ds-icon>
          Strategy
        </dap-ds-stack>
      </dap-ds-button>
      <p style={{margin: 'var(--dds-spacing-200) 0 0 0', fontSize: 'var(--dds-font-size-sm)', color: 'var(--dds-color-text-secondary)'}}>
        Technical planning
      </p>
      
      <dap-ds-button href="/audit" variant="subtle-menu" >
        <dap-ds-stack direction="row">
          <dap-ds-icon name="shield-check-line"></dap-ds-icon>
          Security Audit
        </dap-ds-stack>
      </dap-ds-button>
      <p style={{margin: 'var(--dds-spacing-200) 0 0 0', fontSize: 'var(--dds-font-size-sm)', color: 'var(--dds-color-text-secondary)'}}>
        Code review and security
      </p>
    </div>
  </div>
</dap-ds-navigation-menu-item>
</dap-ds-navigation-menu>
Custom Trigger Elements

Navigation items support custom trigger elements beyond standard buttons.

<dap-ds-navigation-menu>
<dap-ds-navigation-menu-item>
  <div slot="trigger" style={{
    padding: 'var(--dds-spacing-300) var(--dds-spacing-400)',
    borderRadius: 'var(--dds-radius-base)',
    cursor: 'pointer',
    background: 'var(--dds-background-neutral-base)',
    border: '1px solid var(--dds-border-neutral-subtle)',
    display: 'flex',
    alignItems: 'center',
    gap: 'var(--dds-spacing-200)'
  }}>
    <dap-ds-icon name="more-line"></dap-ds-icon>
    Custom Trigger
  </div>
  
  <div style={{padding: 'var(--dds-spacing-200)'}}>
    <dap-ds-button href="/option1" variant="subtle-menu" >
      Option 1
    </dap-ds-button>
    <dap-ds-button href="/option2" variant="subtle-menu" >
      Option 2
    </dap-ds-button>
  </div>
</dap-ds-navigation-menu-item>
</dap-ds-navigation-menu>
Real-World Patterns Main Site Navigation

Implementation of a complete site navigation with branding and user actions.

<header style={{borderBottom: '1px solid var(--dds-border-neutral-subtle)', padding: 'var(--dds-spacing-200)'}}>
<div style={{display: 'flex', alignItems: 'center', justifyContent: 'space-between', maxWidth: '1200px', margin: '0 auto'}}>
  <div style={{display: 'flex', alignItems: 'center', gap: 'var(--dds-spacing-200)'}}>
    <dap-ds-typography variant="h4">
      Your Brand
    </dap-ds-typography>
    
    <dap-ds-navigation-menu activeHref="/products">
      <dap-ds-navigation-menu-item>
        <dap-ds-button slot="trigger" href="/" variant="subtle-menu" >
          Home
        </dap-ds-button>
      </dap-ds-navigation-menu-item>
      
      <dap-ds-navigation-menu-item baseHref="/products">
        <span slot="title">Products</span>
          
          <dap-ds-stack spacing="100">
            <dap-ds-button href="/web-dev" variant="subtle-menu-item">
              <dap-ds-stack spacing="0">
                <dap-ds-stack direction="row">
                  <dap-ds-icon name="tools-line"></dap-ds-icon>
                  Web Development
                </dap-ds-stack>
                <dap-ds-typography variant="description">
                  Build modern web applications
                </dap-ds-typography>
              </dap-ds-stack>
            </dap-ds-button>

            <dap-ds-button href="/mobile" variant="subtle-menu-item">
              <dap-ds-stack spacing="0">
                <dap-ds-stack direction="row">
                  <dap-ds-icon name="cookie-line"></dap-ds-icon>
                  Mobile Apps
                </dap-ds-stack>
                <dap-ds-typography variant="description">
                  iOS and Android development
                </dap-ds-typography>
              </dap-ds-stack>
            </dap-ds-button>
          </dap-ds-stack>
        </dap-ds-navigation-menu-item>
      
        <dap-ds-navigation-menu-item>
          <dap-ds-button slot="trigger" href="/about" variant="subtle-menu" >
            About
          </dap-ds-button>
        </dap-ds-navigation-menu-item>
    </dap-ds-navigation-menu>
  </div>
  
  <dap-ds-button variant="primary" href="/contact">
    Get Started
  </dap-ds-button>
</div>
</header>
Custom Styling

The navigation menu component can be customized using CSS custom properties for layout spacing and popup appearance.

Custom Styling Example
<dap-ds-navigation-menu class="custom-navigation" activeHref="/products">
<dap-ds-navigation-menu-item class="custom-navigation-item">
  <dap-ds-button slot="trigger" href="/" variant="subtle-menu">
    <dap-ds-stack direction="row">
      <dap-ds-icon name="home-6-line"></dap-ds-icon>
      Home
    </dap-ds-stack>
  </dap-ds-button>
</dap-ds-navigation-menu-item>

<dap-ds-navigation-menu-item baseHref="/products" class="custom-navigation-item">
  <span slot="title">Products</span>
  
  <dap-ds-stack spacing="100">
    <dap-ds-button href="/web-dev" variant="subtle-menu-item">
      <dap-ds-stack spacing="0">
        <dap-ds-stack direction="row">
          <dap-ds-icon name="tools-line"></dap-ds-icon>
          Web Development
        </dap-ds-stack>
        <dap-ds-typography variant="description">
          Custom styled dropdown item
        </dap-ds-typography>
      </dap-ds-stack>
    </dap-ds-button>

    <dap-ds-button href="/mobile" variant="subtle-menu-item">
      <dap-ds-stack spacing="0">
        <dap-ds-stack direction="row">
          <dap-ds-icon name="cookie-line"></dap-ds-icon>
          Mobile Apps
        </dap-ds-stack>
        <dap-ds-typography variant="description">
          Enhanced styling example
        </dap-ds-typography>
      </dap-ds-stack>
    </dap-ds-button>
  </dap-ds-stack>
</dap-ds-navigation-menu-item>

<dap-ds-navigation-menu-item class="custom-navigation-item">
  <dap-ds-button slot="trigger" href="/contact" variant="subtle-menu">
    Contact
  </dap-ds-button>
</dap-ds-navigation-menu-item>
</dap-ds-navigation-menu>
.custom-navigation {
    /* Increase spacing between navigation items */
    --dds-navigation-menu-item-gap: var(--dds-spacing-300);
}

.custom-navigation-item {
  /* Customize dropdown appearance */
  --dds-popup-background: var(--dds-background-neutral-subtle);
  --dds-popup-border-radius: var(--dds-radius-large);
  --dds-popup-border-color: red;
  --dds-popup-border-width: 2px;
  --dds-popup-padding: var(--dds-spacing-400);
}
  
.custom-navigation-item dap-ds-button[variant="subtle-menu"] {
  /* Custom button styling for menu items */
  --dds-button-padding-x: var(--dds-spacing-400);
  --dds-button-padding-y: var(--dds-spacing-300);
  --dds-button-border-radius: var(--dds-radius-large);
  
  /* Hover and active states */
  --dds-button-subtle-background-neutral-hover: var(--dds-indigo-600);
  --dds-button-subtle-background-neutral-pressed: var(--dds-indigo-700);
  --dds-button-subtle-text-neutral-hover: var(--dds-button-primary-text-enabled);
}

.custom-navigation-item dap-ds-button[variant="subtle-menu-item"] {
  /* Custom styling for dropdown menu items */
  --dds-button-subtle-menu-item-padding: var(--dds-spacing-300);
  --dds-button-subtle-menu-item-border-radius: var(--dds-radius-base);
  --dds-button-subtle-menu-item-color-bg-hover: var(--dds-indigo-600);
}

Accessibility Built-in Features
  • Full keyboard navigation with Arrow keys, Tab, Enter, and Escape
  • Screen reader support with proper ARIA roles and labels
  • Focus management with automatic dropdown closure
  • Active state announcements for current page/section
Keyboard Navigation
  • Tab: Navigate between navigation items
  • Arrow Down/Up: Open dropdown menus (when available)
  • Enter/Space: Activate navigation links or toggle dropdowns
  • Escape: Close open dropdown menus
  • Arrow Left/Right: Navigate horizontally between items (horizontal orientation)
ARIA Support

The component automatically provides:

  • role="navigation" for the main container
  • role="none" for list item containers
  • role="menu" for dropdown content areas
  • aria-expanded states for dropdown triggers
  • aria-controls linking triggers to their dropdowns
Technical Details

The navigation menu component is built on top of the popup component, combining navigation semantics with positioning capabilities. It automatically manages active states, dropdown interactions, and keyboard navigation to provide a complete navigation solution for web applications.

Importing
import { DapDSNavigationMenu } from 'dap-design-system/dist/dds'
Importing React
import { DapDSNavigationMenuReact } from 'dap-design-system/dist/react'
Attributes
PropertyTypeDefaultDescription
activeHrefstringThe currently active href for highlighting active navigation items.
orientation'horizontal', 'vertical''horizontal'The orientation of the navigation menu.
fullWidthbooleanfalseWhether the navigation menu should take full width of the screen.
Slots
NameDescription
(default)The navigation menu list and items.
Events
Event NameDescriptionType
dds-navigation-item-clickFired when a navigation item is clicked.{href: string, event: Event }
CSS Parts
Part NameDescription
baseThe main navigation menu container.
CSS Custom Properties

No CSS custom properties available.

Components Navigation Menu Item <dap-ds-navigation-menu-item/> Attributes
PropertyTypeDefaultDescription
iconstringThe name of the icon to display in the trigger.
ariaLabelledBystringThe name of the element that labels the navigation dropdown.
activeHrefstringThe href of the navigation item that is active.
baseHrefstringThe href of the navigation item. If provided, the navigation item will be active if the href is a substring of the activeHref. It is useful for dropdowns that are not direct children of the navigation menu.
exactHrefbooleanfalseWhether the navigation item should be active if the href is exactly the same as the activeHref.
placement'top', 'right' , 'bottom' , 'left' , 'top-start' , 'top-end' , 'bottom-start' , 'bottom-end' , 'left-start' , 'left-end' , 'right-start' , 'right-end''bottom-start'The placement of the popup.
overflowbooleantrueWhether the popup should overflow.
floatingStrategy'absolute', 'fixed''fixed'The floating strategy of the popup.
size'xs', 'sm' , 'lg'The size of the popup.
disabledbooleanThe disabled state of the popup.
openedbooleanThe open state of the popup.
offsetnumberThe offset of the popup.
syncbooleanWhether the popup should sync its width with the trigger.
maxHeightnumber, 'auto'The maximum height of the popup.
maxWidthnumber, 'auto'The maximum width of the popup.
hasArrowbooleanWhether the popup has an arrow.
fullWidthbooleanWhether the popup should take full width of the screen.
Slots
NameDescription
triggerThe trigger element (link, button, etc.) for this navigation item.
titleThe title of the navigation item.
(default)The dropdown content (only used if trigger slot is provided).
Events
Event NameDescriptionType
dds-navigation-item-clickFired when a navigation item is clicked.{href: string, event: Event }
dds-navigation-dropdown-openFired when a navigation dropdown is opened.{item: DapDSNavigationMenuItem }
dds-openedFired when the popup is opened.{void }
dds-closedFired when the popup is closed.{void }
dds-closeFired when the popup should be closed.{void }
CSS Parts
Part NameDescription
baseThe base part of the navigation item.
triggerThe trigger element part.
contentThe dropdown content part.
popupThe main popup container.
arrowThe arrow of the popup.
CSS Custom Properties
Property NameDescription
--dds-popup-z-indexZ-index of the popup.
--dds-popup-paddingDefault padding of the popup.
--dds-popup-padding-xsPadding of the popup when size is xs.
--dds-popup-padding-lgPadding of the popup when size is lg.
--dds-popup-border-widthBorder width of the popup.
--dds-popup-border-radiusBorder radius of the popup.
--dds-popup-border-colorBorder color of the popup.
--dds-popup-backgroundBackground color of the popup.
--dds-popup-colorText color of the popup.
--dds-popup-arrow-sizeSize of the popup arrow.