lavary/laravel-menu

Defining an HTML-Attribute for the HTML A-Tag

lsblsb opened this issue · 1 comments

First: Thanks for your great work.

I have read all the documentation, but could not find any information on how to add a class-attribute to an a-tag inside the li-tag of a unordered list. I need to set nav-link, dropdown-toggle, dropdown-item classes to generate a bootstrap 5 menu in a simple way (by just including the ul-menu inside the surrounding bootstrap navbar configuration).

Have i missed something, or is this not possible currently?

After rereading, I found the crucial clue in the section "Manipulating Links" of the documentation (this info could be linked in the HTML attributes section of the documentation in my opinion).

It works like this (example code):

[...]
$m->add('MenuElement', ['route' => 'my.route'])->link->attr(['class'=>'nav-link']);