Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a class to each li #39

Closed
bbashy opened this issue Jan 30, 2017 · 2 comments
Closed

Adding a class to each li #39

bbashy opened this issue Jan 30, 2017 · 2 comments

Comments

@bbashy
Copy link

bbashy commented Jan 30, 2017

Hi,

I've looked through the docs and seen how to add classes to the ul and the a but not the li.

Bootstrap has nav-item on the li and I can't seem to work out how to add that within the ->route() items.

Menu::macro('main', function() {
    $menu = Menu::new()
        ->addClass('navbar-nav mr-auto')
        ->addItemClass('nav-link')
        ->route('candidates.index', 'Candidates')
        ->route('requisitions.index', 'Requisitions')
        ->route('accounts.index', 'Accounts')
        ->route('contacts.index', 'Contacts')
        ->setActiveFromRequest()
        ;

    return $menu;
});

Which generates

<ul class="navbar-nav mr-auto">
    <li>
        <a href="https://domain.dev/candidates" class="nav-link">Candidates</a>
    </li>
    <li class="active">
        <a href="https://domain.dev/requisitions" class="nav-link">Requisitions</a>
    </li>
    <li>
        <a href="https://domain.dev/accounts" class="nav-link">Accounts</a>
    </li>
    <li>
        <a href="https://domain.dev/contacts" class="nav-link">Contacts</a>
    </li>
</ul>

but I need this on each item

<li class="nav-item">

Thanks!

@sebastiandedeyne
Copy link
Member

There's also an addItemParentClass method, which should add the class on the li tag instead of the link.

@bbashy
Copy link
Author

bbashy commented Jan 30, 2017

Ah yes, worked! I searched for "parent" and that didn't show up :( should of searched parent class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants