CollapsibleNavMenu 1.0.0.2

dotnet add package CollapsibleNavMenu --version 1.0.0.2
                    
NuGet\Install-Package CollapsibleNavMenu -Version 1.0.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CollapsibleNavMenu" Version="1.0.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CollapsibleNavMenu" Version="1.0.0.2" />
                    
Directory.Packages.props
<PackageReference Include="CollapsibleNavMenu" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CollapsibleNavMenu --version 1.0.0.2
                    
#r "nuget: CollapsibleNavMenu, 1.0.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=CollapsibleNavMenu&version=1.0.0.2
                    
Install CollapsibleNavMenu as a Cake Addin
#tool nuget:?package=CollapsibleNavMenu&version=1.0.0.2
                    
Install CollapsibleNavMenu as a Cake Tool

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

dotnet add package CollapsibleNavMenu

Option 2: Project Reference (for local/private use)

  1. Clone or copy the CollapsibleNavMenu project folder.
  2. 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 with DefaultNavMenuProvider 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

https://github.com/eodknight23/CollapsibleNavMenu


πŸ™Œ 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0.2 110 3/17/2025
1.0.0.1 110 3/17/2025
1.0.0 106 3/17/2025