CollapsibleNavMenu 1.0.0.2
dotnet add package CollapsibleNavMenu --version 1.0.0.2
NuGet\Install-Package CollapsibleNavMenu -Version 1.0.0.2
<PackageReference Include="CollapsibleNavMenu" Version="1.0.0.2" />
<PackageVersion Include="CollapsibleNavMenu" Version="1.0.0.2" />
<PackageReference Include="CollapsibleNavMenu" />
paket add CollapsibleNavMenu --version 1.0.0.2
#r "nuget: CollapsibleNavMenu, 1.0.0.2"
#addin nuget:?package=CollapsibleNavMenu&version=1.0.0.2
#tool nuget:?package=CollapsibleNavMenu&version=1.0.0.2
CollapsibleNavMenu
CollapsibleNavMenu is a modular, reusable, and responsive Razor Class Library (RCL) that provides a powerful, dynamic, and role-aware navigation component for Blazor WebAssembly and Blazor Server applications.
Built for real-world production use, it supports multi-level navigation, JSON-configurable menu structures, role-based filtering, and adaptive behavior for both mobile and desktop users.
π¦ Features
- β Responsive layout (mobile and desktop friendly)
- β Multi-level (nested) navigation with expandable submenus
- β
Role-based filtering using
AuthenticationState
- β JSON-based dynamic menu configuration
- β Smooth slide-in/slide-out sidebar transitions
- β Razor Class Library (RCL) β plug-and-play integration
- β Clean architecture using Dependency Injection
- β
Optional admin-editable
navlinks.json
menu file
π Installation
Option 1: Via NuGet (Recommended)
dotnet add package CollapsibleNavMenu
Option 2: Project Reference (for local/private use)
- Clone or copy the
CollapsibleNavMenu
project folder. - Add a reference to your Blazor app:
- Right-click solution β Add β Existing Project
- Right-click your Blazor app β Add β Project Reference β CollapsibleNavMenu
π Project Structure
CollapsibleNavMenu/
βββ Components/
β βββ CollapsibleNavMenu.razor
β βββ CollapsibleNavMenu.razor.cs
β βββ CollapsibleNavMenu.razor.css
βββ Models/
β βββ NavLinkItem.cs
βββ Services/
β βββ INavMenuProvider.cs
β βββ JsonNavMenuProvider.cs
β βββ DefaultNavMenuProvider.cs
βββ wwwroot/
β βββ config/
β βββ navlinks.json
βββ _Imports.razor
π§ Usage
1. Add the Component
In your consuming app (e.g., MainLayout.razor
):
@using CollapsibleNavMenu.Components
<CollapsibleNavMenu />
2. Register the Navigation Provider
In Program.cs
:
using CollapsibleNavMenu.Services;
builder.Services.AddScoped<INavMenuProvider, JsonNavMenuProvider>();
You can swap
JsonNavMenuProvider
withDefaultNavMenuProvider
or a custom implementation.
π Sample navlinks.json
[
{
"title": "Home",
"url": "/",
"iconClass": "oi oi-home",
"roles": []
},
{
"title": "Projects",
"iconClass": "oi oi-folder",
"roles": ["User", "Admin"],
"children": [
{
"title": "Corporate",
"url": "/projects/corporate",
"iconClass": "oi oi-briefcase"
},
{
"title": "Personal",
"url": "/projects/personal",
"iconClass": "oi oi-person"
}
]
}
]
β Role-based filtering is automatic based on
[CascadingParameter] AuthenticationState
.
β¨ Responsive Behavior
Device | Behavior |
---|---|
Mobile | Sidebar collapses and slides left when a submenu is opened |
Desktop | Main menu and one submenu visible side-by-side (up to 2 panes) |
UX Rule | βHomeβ menu is pinned when there are β€2 sidebars |
π Advanced Customization Road Map
- Create your own provider: implement
INavMenuProvider
- Replace hardcoded nav items with CMS/API-driven content
- Extend
NavLinkItem
with custom metadata (e.g., icons, badges, tags) - Add breadcrumb trail, nested collapsing, or theming support
π License
MIT License
Β© [Evan Knight / Other Gordon Solutions]
Feel free to use, modify, and distribute with attribution.
π Repository
π Contributing
Pull requests and issue reports are welcome! Please follow standard Blazor component best practices and submit tests where applicable.
π¬ Contact
For questions, support, or integration guidance, contact:
π§ eodknight23@gmail.com
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net8.0
- Microsoft.AspNetCore.Components.Authorization (>= 8.0.14)
- Microsoft.AspNetCore.Components.Web (>= 8.0.14)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.