Mobile Navigation
This example demonstrates creating responsive mobile navigation menus including hamburger menus, slide-out panels, and accordion navigation.
Overview
Basic Mobile Menu
HTML Structure
@using Umbraco.Community.UmbNav.Core.Models
@using Umbraco.Community.UmbNav.Core.Enums
@{
var home = Model.Root();
var navigation = home?.Value<IEnumerable<UmbNavItem>>("mainNavigation");
}
<!-- Mobile Header -->
<header class="mobile-header">
<a href="@home?.Url()" class="mobile-header__logo">
<img src="/images/logo.svg" alt="Site Logo" />
</a>
<button class="mobile-header__toggle"
aria-label="Open menu"
aria-expanded="false"
aria-controls="mobile-nav">
<span class="hamburger">
<span></span>
<span></span>
<span></span>
</span>
</button>
</header>
<!-- Mobile Navigation Panel -->
<nav id="mobile-nav" class="mobile-nav" aria-label="Main navigation" hidden>
<div class="mobile-nav__header">
<span class="mobile-nav__title">Menu</span>
<button class="mobile-nav__close" aria-label="Close menu">
<span>×</span>
</button>
</div>
<ul class="mobile-nav__list">
@if (navigation != null)
{
foreach (var item in navigation)
{
@await Html.PartialAsync("_MobileNavItem", item, new ViewDataDictionary(ViewData) { { "CurrentPage", Model } })
}
}
</ul>
</nav>
<!-- Overlay -->
<div class="mobile-nav__overlay" hidden></div>_MobileNavItem.cshtml
CSS
JavaScript
Slide-Out Panel with Push Effect
Full-Screen Overlay Menu
Bottom Sheet Navigation
View Component Implementation
MobileNavigationViewComponent.cs
Usage
Accessibility Best Practices
Last updated
Was this helpful?