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

Menu Laravel Package

spatie/menu

Fluent, extensible menu builder for Laravel. Compose navigation with a clean API, render as HTML, and customize output via presenters and macros. Supports active state handling, links, submenus, and easy integration with Blade and your app’s routing.

View on GitHub
Deep Wiki
Context7

title: Your First Menu weight: 1

Let's get things started by building a simple menu with two links. All of the following examples are using classes from the Spatie\Menu namespace.

<ul>
    <li><a href="/">Home</a></li>
    <li><a href="/about">About</a></li>
</ul>

Menu's are created via the new factory method.

$menu = Menu::new();

Links are created with the to factory method, which requires a url and a string of text (or html) as parameters.

$link = Link::to('/', 'Home');

A menu can be instantiated with an array of items, or items can be added fluently with the add method.

// With an array:
$menu = Menu::new([
    Link::to('/', 'Home'),
    Link::to('/about', 'About'),
]);

// Or fluently:
$menu = Menu::new()
    ->add(Link::to('/', 'Home'))
    ->add(Link::to('/about', 'About'));

When we render or echo the menu, it will output our intended html string.

// Via the `render` method:
echo $menu->render();

// Or just through `__toString`:
echo $menu;
<ul>
    <li><a href="/">Home</a></li>
    <li><a href="/about">About</a></li>
</ul>
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.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle