Skip to main content

Mobilenav

Mobile navigation panel with two menu slots, primary (top) and secondary (bottom). Designed to live inside a drawer. The drawer handles the slide-in, focus management, and dismissal; mobilenav provides the menu structure and styling.

Stories show the panel on its own and composed inside a drawer.

Usage​

When to use

  • Off-canvas main navigation on small viewports
  • Secondary "account" or "utility" menus that piggy-back on the primary mobile drawer
  • Any narrow surface that needs a full vertical link list with optional collapsible submenus

When not to use

  • Primary site navigation on desktop - use navbar
  • Section navigation inside a sidebar - use sidenav
  • Page-level table of contents - use toc

Do

  • Compose mobilenav inside a drawer so the slide-in, backdrop, and focus behavior come from the drawer (use a modal drawer for a full focus trap)
  • Keep top-level items short so they fit on narrow viewports without truncation
  • Use the secondary slot for account, language, and utility links rather than mixing them into primary

Don't

  • Don't render mobilenav directly on the page without a drawer wrapper - it has no dismissal behavior of its own
  • Don't deeply nest submenus - mobile keyboards and one-thumb scroll make three or more levels hard to reach
  • Don't replicate the desktop megamenu structure - mobilenav is intentionally vertical and one-column

API​

Slots​

SlotRequiredDescription
primaryYesPrimary menu items rendered at the top of the panel. Array of item objects with url, text, icon, description, badge, is_active_trail, is_current, is_disabled, is_external, is_section, is_divider, and nested items.
secondary-Secondary menu items rendered at the bottom of the panel. Same item object shape as primary.

Props​

PropTypeDefaultDescription
primary_labelstringPrimaryAccessible label for the primary menu.
secondary_labelstringSecondaryAccessible label for the secondary menu.
is_collapsiblebooleantrueWhen true, parent items with nested children become inline expand/collapse triggers via the collapsible utility.
classesarray-Additional CSS class words merged into the root element.
attributesobject-Additional HTML attributes spread on the root element.

Classes​

ClassCapabilityDefaultDescription
.subtleEmphasis-Lower emphasis; a muted, quieter weight.
.neutralEmphasisYesDefault emphasis; the standard weight at balanced contrast.
.accentEmphasis-Higher emphasis; a stronger, louder weight.
.smSize-Small.
.mdSizeYesMedium.
.lgSize-Large.

Examples​

Sizes​

The three size values, which scale the link font size and the link padding together.

Primary only​

Panel rendered with only the primary slot - useful when secondary actions live elsewhere in the chrome.

In drawer​

Mobilenav composed inside a drawer triggered by a hamburger button; backdrop click and Escape close the drawer with no story-side JS.

Accessibility​

  • WCAG 2.2 AA
  • Each menu slot exposes a labeled <nav> landmark via aria-label
  • With is_collapsible, each parent item gains a toggle button whose aria-expanded/aria-controls are wired by the collapsible utility
  • When composed inside a modal drawer (is_modal), focus is trapped inside it and returned to the trigger on close
  • Reduced-motion preferences are honored by the drawer slide animation

Dependencies​

  • drawer - off-canvas surface mobilenav is designed to live inside
  • collapsible - drives the optional submenu expand/collapse when is_collapsible is set
  • navbar - desktop horizontal navigation with megamenu support
  • sidenav - persistent vertical navigation for sidebars and section trees