Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Menu Laravel Package

spatie/laravel-menu

Build HTML menus in Laravel with a fluent API. Generate links from routes/actions/URLs, group items, add attributes/classes, and automatically set the active item from the current request. Extensible via macros; renders to HTML ready for Blade.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Unified Navigation for Multi-Product Ecosystems: Standardizes menu structures across SaaS platforms, admin panels, or multi-tenant applications, reducing user onboarding friction and design inconsistencies. Aligns with design system principles by centralizing navigation logic in a maintainable, code-driven format (vs. scattered Blade templates). Critical for products with shared UI components (e.g., spatie/laravel-menu’s macros enable reusable menus like Menu::macro('globalHeader', ...) across microservices).

  • Accelerated Feature Velocity: Eliminates repetitive menu boilerplate (e.g., active state checks, route generation, or conditional rendering) to reduce development time by 50–70% for complex menus. Example: A dashboard with 20+ route-aware items transitions from manual Blade logic to a declarative macro (Menu::macro('dashboardSidebar', ...)), freeing engineers to focus on core features. Supports agile roadmaps by abstracting away low-value UI plumbing.

  • Build vs. Buy Decision: Justifies a low-risk, high-reward adoption by leveraging a mature package (980+ stars, MIT license, Laravel 13 support) with zero long-term maintenance overhead. Avoids reinventing the wheel for a solved problem, reducing technical debt and aligning with Spatie’s track record of Laravel-first solutions (e.g., spatie/laravel-permission). Ideal for teams prioritizing speed-to-market over customization.

  • Roadmap Enablers:

    • Dynamic Menus: Future-proofs for API-driven menus (e.g., fetching items from a headless CMS or database) via the package’s extensible Link and View item implementations.
    • Permission Systems: Integrates seamlessly with Laravel’s Gate or Policy classes via actionIfCan() or addIfCan(), enabling role-based menus without custom logic.
    • Internationalization: Supports localized menus via macro parameters (e.g., Menu::macro('languageSelector', fn() => ...)) or Blade translations.
    • Theming/Dark Mode: Adds CSS classes or data attributes (e.g., ->class('dark-mode')) for consistent styling across themes.
    • Headless/SPA Hybrids: Provides a server-side menu generator that can be consumed by frontend frameworks (e.g., via JSON API endpoints or Inertia.js).

When to Consider This Package

  • Adopt When:

    • Your Laravel application requires reusable, route-aware menus (e.g., admin panels, dashboards, or multi-page apps) with active state highlighting (setActiveFromRequest()).
    • You need to reduce UI duplication across features (e.g., shared headers/footers) or accelerate development for navigation-heavy products (e.g., SaaS platforms).
    • Your team lacks dedicated frontend infrastructure but needs semantic HTML menus (e.g., ARIA support, proper nesting) without manual Blade complexity.
    • You prioritize maintainability over customization (e.g., avoiding spaghetti Blade templates or JavaScript-based solutions).
    • You’re using Laravel 8+ and PHP 8+ (the package drops PHP 7.x support in v4.0.0).
  • Look Elsewhere If:

    • You need highly dynamic menus (e.g., real-time updates without page reloads) where a client-side solution (e.g., React/Vue components) is preferable.
    • Your navigation requires complex interactivity (e.g., dropdowns with custom animations) beyond basic HTML rendering. Consider pairing this with a frontend framework or CSS library (e.g., Tailwind, Bootstrap).
    • You’re on Laravel < 8 or PHP < 8.0 (use v3.x of the package or a legacy alternative).
    • Your use case demands serverless or edge rendering (e.g., Vercel Edge Functions), where PHP/Laravel may not be ideal.
    • You need deep customization (e.g., Web Components or WebAssembly integration) that the package doesn’t support out of the box.

How to Pitch It (Stakeholders)

For Executives: "This package lets us build and update navigation menus 3x faster while ensuring consistency across our Laravel products. Instead of manually coding menus in Blade—where errors, duplication, and updates become a nightmare—we’ll use a reusable, macro-based system (e.g., Menu::macro('adminSidebar')) that auto-highlights active pages and integrates with our permission system. It’s a zero-maintenance upgrade (MIT-licensed, 980+ stars) that reduces dev time and aligns with our design system goals. For example, adding a new menu item to our dashboard now takes 5 minutes instead of an hour."

For Engineers: *"Spatie’s laravel-menu gives us a fluent, Laravel-native way to define menus in code (not Blade) with built-in support for:

  • Route-aware links (action(), route()) and active state (setActiveFromRequest()).
  • Macros for reusable menus (e.g., Menu::macro('globalHeader')) and conditional logic (actionIfCan() for permissions).
  • Blade integration ({!! Menu::main() !!}) with zero JavaScript overhead. It’s lightweight, actively maintained, and drops into any Laravel 8+ app in 10 minutes. No more fighting with nested Blade if statements or hardcoded active classes—just clean, scalable navigation logic."*
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport