A menu builder for Laravel using Bootstrap's markup.
kalnoy/illuminate-menu is a Laravel package for a menu builder for laravel using bootstrap's markup..
It currently has 24 GitHub stars and 14.575 downloads on Packagist (latest version v1.3.5).
Install it with composer require kalnoy/illuminate-menu.
Discover more Laravel packages by kalnoy
or browse all Laravel packages to compare alternatives.
Last updated
A menu builder for Laravel 4-5 using Bootstrap's markup.
Note that this package is shipped with no styles nor scripts, you have to download them manually from Twitter Bootstrap's site.
Install using Composer:
composer require kalnoy/illuminate-menu:~2.0
Add a service provider:
'providers' => [
'Illuminate\Html\MenuServiceProvider',
],
And a facade:
'aliases' => [
'Nav' => 'Illuminate\Support\Facades\Nav',
'Dropdown' => 'Illuminate\Support\Facades\Dropdown',
],
Rendering navigation:
{!! Nav::render($items, $attributes) !!}
Where $attributes is optional array of html attributes for ul element.
Rendering a list of menu items without wrapper element:
<ul>{!! Nav::items($items) !!}</ul>
Rendering a single menu item:
{!! Nav::item($label, $url) !!}
{!! Nav::item($label, $options) !!}
{!! Nav::item($options) !!}
See a list of available options below.
Basic example:
Nav::render([
'Link to url' => 'bar',
'Link to external url' => 'http://bar',
[ 'label' => 'Link to url', 'url' => 'bar' ],
'Link to route' => [ 'route' => [ 'route.name', 'foo' => 'bar' ] ],
]);
Rendering an item with a drop down menu:
{!! Nav::item([
'label' => 'Settings',
'icon' => 'wrench',
'dropdown' => [
'Foo' => 'bar',
'-', // divider
'Logout' => [ 'route' => 'logout_path' ],
],
]) !!}
Controlling whether the item is visible:
{!! Nav::item([
'label' => 'Foo',
'url' => 'bar',
'visible' => function () { return Config::get('app.debug'); },
] !!}
You can specify an array of following options:
label is a label of the item, automatically translated, so you can specify lang string idhref is a raw href attribute on the linkurl is the url which can be a full URI or local pathroute to specify a route, possibly with parameterssecure; specify true to make url be secure (doesn't affect route option)Changing the state of the item:
visible is a boolean value or closure to specify whether the item is visibleactive is a boolean value or closure to specify whether to add active class to item; if not specified, determined
automatically based on current urldisabled is a boolean value or closure to specify whether the menu item is disabledPresentation options:
icon is a glyphicon id, i.e. pencilbadge is a value for badge (scalar or closure)dropdown is a collection of items for drop down menuThough this menu builder intended to be used together with bootstrap markup, you can customize it however you like by
extending Illuminate\Html\MenuBuilder class and overriding base methods.