Appending and Prepending Html

You can append and prepend html outside of the ul tag with similarly named functions. This is useful for submenu titles or separators.

    ->add(Link::to('/title/subpage', 'Subpage'))
        <a href="/title/subpage">Subpage</a>

If you only want to add html in certain conditions, you can use appendIf and prependIf.

$displayTitles = false;
$displayRulers = true;

    ->prependIf($displayTitles, '<h2>Title</h2>')
    ->add(Link::to('/title/subpage', 'Subpage'))
    ->appendIf($displayRulers, '<hr>');

You can also wrap the menu in an element.

Menu::new()->wrap('div', ['class' => 'nav']);
<div class="nav">