Menu and Tab Utils

A Laravel library to to build menus and tabs navigation utilities, based on Boostrap 5 CSS Framework. Current version: 2.2.0. Project on GitHub. Project on Packagist. This demosite sources available here.

Vertical navigation

Here we build a vertical Bootstrap navigation menu. In your controller, define a variable this way and pass variable to the view parameters:


$element = MenuUtils::init('vertical-nav', //main nav id
[
  'ulclass' => 'nav flex-column', // main class
  'current' => 'link6', // sets current ative element
  'menu' => [ // defines the menu content
    'link5' => [  // array key is the menu element's id. Be sure to define an id not used elsewhere in doc
      'title' => 'Link 1', // label of menu element
      'target' => route('menuutils'), // route called in link
    ],
    ...
    'link8' => [
      'title' => 'Dropdown menu',
      'dropdown' => [ // dropdown menu replaces default target
        'link8-1' => [ // drowpdown items are defined same way as level one items
          'title' =>'Link 4.1',
          'target' => route('menuutils'),
        ],
        ...
      ]
    ],
  ]
]);
return view('template', ['element' => $element]);

Then just insert the variable in the appropriate section in your view: {!! $element !!}

Example