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.

Tabs with view content

Here we build tabs, where tab content is defined by Laravel Blade templates. In your controller, define a variable this way and pass variable to the view parameters:


$element = TabUtils::init('tabs-2',  // main tab id
[
  'current' => 'tab5', // sets current ative element
  'tabs' => [ // sets tabs elements
    'tab5' => [ // array key is the tab element's id. Be sure to define an id not used elsewhere in doc
      'title' => 'Tabs 1', // label of tab element
      'view' => 'tabs.tabcontent', // path of blade template
      'viewparams' => [ // parameters to be passed to view
        'title' => 'Tabs 1 content',
      ],
    ],
...
  ]
]);
return view('template', ['element' => $element]);

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

Example




Tabs 1 content

Lorem ipsum ...

Tabs 2 content

Lorem ipsum ...

Tabs 3 content

Lorem ipsum ...

Tabs 4 content

Lorem ipsum ...