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: Parent Attributes weight: 2

The Menu and Link, and Html classes also use the ParentAttributes trait, which allows you to add attributes to their parent elements (which are generally a ul or li tags) via setParentAttribute and addParentClass.

Menu::new()
    ->add(Html::raw('<img src="/my-avatar">')
        ->setParentAttribute('id', 'user-123')
        ->addParentClass('-has-avatar')
    );
<ul>
    <li id="user-123" class="-has-avatar">
        <img src="/my-avatar">
    </li>
</ul>

These attributes will only be rendered if the elements are rendered inside of a parent (e.g. a link or a sub menu).

If you want to add classes or set attributes to all items' parents in a menu, the Menu class provides some convenience methods: addItemParentClass, setItemParentAttribute.

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.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui