PHPackages                             seblhaire/menuandtabutils - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. seblhaire/menuandtabutils

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

seblhaire/menuandtabutils
=========================

A Laravel library to to build menus and tabs navigation utilities, based on Boostrap 5 CSS Framework.

2.4.0(1mo ago)042MITPHPPHP &gt;=8.4

Since Jun 25Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/seblhaire/menuandtabutils)[ Packagist](https://packagist.org/packages/seblhaire/menuandtabutils)[ RSS](/packages/seblhaire-menuandtabutils/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (11)Used By (0)

Menu and Tab Utils
==================

[](#menu-and-tab-utils)

[By Sébastien L'haire](http://sebastien.lhaire.org)

A Laravel library to to build menus and tabs navigation utilities, based on [Boostrap](https://getbootstrap.com/) 5 CSS Framework. Package demo available [here](https://sebastien.lhaire.org/menuutils).

[![MenuAndTabUtils example image](menutabutils.png)](menutabutils.png)

Installation
============

[](#installation)

1. install package

`composer require seblhaire/menuandtabutils`

2. Composer will automatically link the package with Laravel. But you still can explicitly add provider and facade to your `config/app.php`:

```
'providers' => [
	Seblhaire\MenuAndTabUtils\MenuServiceProvider::class,
]
```

Javascript and stylesheets
==========================

[](#javascript-and-stylesheets)

On a webpage, every JS library and CSS stylesheets can be linked separately. If you choose this classical way, first download and install Bootstrap. Then publish package files as explained above and put following tags in your template:

Websites often use many libraries and stylesheets, and browsers must download many files before the site can be rendered properly. Modern websites come with a single compressed JavaScript file which concatenates necessary scripts; same principle for stylesheets. With Laravel you can use [Laravel Mix](https://github.com/JeffreyWay/laravel-mix) to compile files.

Use [NPM](https://www.npmjs.com/) package manager : `npm install bootstrap`

Then your js source file should be something like this:

```
require('bootstrap');
```

For your stylesheet:

```
@import '~bootstrap/scss/bootstrap';
```

Config files
============

[](#config-files)

Accessible through

```
config('menuutils')
config('tabutils')
```

These default values are used by tools in next sections. In case you need to change default values, use command `php artisan vendor:publish` and chose the appropriate package in the list. Then config files will be available in file `config/vendor/seblhaire/`.

MenuUtils
=========

[](#menuutils)

```
MenuUtils::init(string $id, array $data)
```

This simple helper assigns a `` menu to a variable.

Parameters:
-----------

[](#parameters)

- `id`: id of main nav
- `data`: array parameter. Content:
    - `menu`: **mandatory** array of value to build menu items. Cf below.
        - `current`: id of menu element that is active, i.e. highlighted. Should not be an dropdown menu item.
        - `ulclass`: class of nav main `` element. For a vertical menu: `nav flex-column`. Default: `nav`.
        - `ulattr`: array of attributes that must be added to nav main ``. Default: empty array.
        - `liclass`: class of menu elements ``. Default: `nav-item`,
        - `liattr`: array of attributes that must be added to menu `` elements. Default: empty array.
        - `aclass`: class of menu element link ``: Default: `nav-link`.
        - `lidropdwn`: class of menu element `` that contains dropdown menu. Default: `nav-item dropdown`.
        - `adroptoggle`: class of menu element link `` that opens a dropdown menu, Default: `nav-link dropdown-toggle`.
        - `dropdwnmenuclass`: class of `` that contains dropdown menu items. Default: `dropdown-menu`.
        - `dropitem`: class of dropdown menu's elements ``. Default: `dropdown-item`.
        - `dropdivider`: class of dropdown menu divider (`` element). Default: `dropdown-divider`.
        - `active`: class of current item. Default: `"active"`

Define menu elements
--------------------

[](#define-menu-elements)

Here are the details to build your navigation menu in `menu` parameter.

```
$element = MenuUtils::init('simple-nav',
[
  'current' => 'link1',
  'menu' => [ // defines the menu content
    'link1' => [
      'title' => 'Link 1',
      'target' => route('menuutils'),
    ],
    ...
		'link3' => [
			'icon' => '',
			'title' => 'Tools',
			'target' => route('menuutils'),
		],
    'link4' => [
      'title' => 'Link 4',
      'dropdown' => [ // dropdown menu replaces default target
        'link4-1' => [ // drowpdown items are defined same way as level one items
          'title' =>'Link 4.1',
          'target' => route('menuutils'),
        ],
        ...
        'sep' => null, // a separator is drawn if array value is null
      ]
    ],
  ]
]);

```

Array keys are used for menu element id. Values are in a sub-array.

- `icon`: image or icon to be displayed in menu item. Html code. Default: unset or empty.
- `title`: **mandatory** element text. If icon is set, title is displayed on mouse hover.
- `target`: link target, eg. route. Not used if `dropdown` is set. Default empty.
- `attributes`: array of key-value pairs for additional parameters for ``.
- `liattr`: array of key-value pairs for additional parameters for ``.
- `dropdown`: array of values. In this array, if the value for a key is null, a menu divider is drawn. Parameters are the same as the top level menu items, except `dropdown`.

Usage
-----

[](#usage)

In your controller, pass the result to a variable:

`$menu = MenuUtils::init('myid', [...]);`

If `current` parameter is not defined in parameters, you can use this method:

`$menu->setCurrent('myid')`

Note that item should not be a dropdown menu element. Then pass this variable to a view:

```
return view('mybladetemplate', [
		'menu' => $menu
]);

```

And in your Blade template, insert your variable at the appropriate line:

`{!! $menu !!}`

A page can have several menus. In this case, assign each menu to a different variable.

BreadcrumbUtils
===============

[](#breadcrumbutils)

```
BreadcrumbUtils::init(string $id, array $data)
```

This simple helper assigns a `` menu to a variable.

Parameters:
-----------

[](#parameters-1)

- `id`: id of main nav
- `data`: array parameter. Content:
    - `menu`: **mandatory** array of value to build menu items. Cf below.
        - `navclass`: class of nav element ``. Default: ''.
        - `navattr`: array of key-attributes values for ``. Default: `['aria-label' => "breadcrumb"]`.
        - `olclass`: class of list ``. Default: `breadcrumb`.
        - `olattr`: array of key-value pairs for element ``. Default: empty array.
        - `liclass`: class of list element ``. Default: `breadcrumb-item`.
        - `liattr`: array of key-value pairs for element ``. Default: empty array.
        - `active`: class of current item. Default: `"active"`.

Define menu elements
--------------------

[](#define-menu-elements-1)

Here are the details to build your navigation menu in `menu` parameter.

```
$element = BreadcrumbUtils::init('breadcrumb-nav', //main nav id
[
  'menu' => [
    'link-9' => [
      'icon' => '&lt;i class="fas fa-home fa-lg"&gt;&lt;/i&gt;',
      'title' => 'Home',
      'target' => route('menuutils', ['type' => 'breadcrumbnav'])
    ],
    'link-10' => [
      'title' => 'Second breadcrumb',
      'target' => route('menuutils', ['type' => 'breadcrumbnav'])
    ],
    'link-11' => [
      'title' => 'Third breadcrumb'
    ],
  ]
]);

```

Array keys are used for menu element id. Values are in a sub-array.

- `icon`: image or icon to be displayed in menu item. Html code. Default: unset or empty.
- `title`: **mandatory** element text. If icon is set, title is displayed on mouse hover.
- `target`: link target, eg. route. Not used if `dropdown` is set. Default empty.
- `attributes`: array of key-value pairs for additional parameters for ``.

Usage
-----

[](#usage-1)

In your controller, pass the result to a variable:

`$breadcrumb = BreadcrumbUtils::init('myid', [...]);`

Current element is always the last one. &lt;Then pass this variable to a view:

```
return view('mybladetemplate', [
		'breadcrumb' => $breadcrumb
]);

```

And in your Blade template, insert your variable at the appropriate line:

`{!! $breadcrumb !!}`

A page can have several breadcrumbs. In this case, assign each menu to a different variable.

TabUtils
========

[](#tabutils)

```
TabUtils::init(string $id, array $data)
```

This helper builds the code for tabs and tab contents.

Parameters:
-----------

[](#parameters-2)

- `id`: id of tab nav
- `data`: array parameter. Content:
    - `tabs`: **mandatory** array of value to build tab items. Cf below.
    - `current`: id of menu element that is active, i.e. highlighted and open.
    - `ulclass`: class of nav tabs. Default: `nav nav-tabs`.
    - `ulattr`: array of attributes that must be added to nav main ``. Default: empty array.
    - `liclass`: class of nav element ``. Default: `nav-item`.
    - `liattr`: array of attributes that must be added to nav main ``. Default: empty array.
    - `btnclass`: class of element ``. Default: `nav-link`.
    - `tabcontentclass`: class of tab content main ``. Default: `tab-content`.
    - `maindivattr`: array of attributes that must be added to tab content main ``. Default: empty array.
    - `tabdivclass`: class of tab element content ``. Default: `tab-pane fade`.
    - `tabcontentattr`: array of attributes that must be added to ab element content ``. Default: empty array.
    - `activetab`: class of current tab element content. Default: `show active`.
    - `active`: class of current item. Default: `"active"`

Define tab elements
-------------------

[](#define-tab-elements)

Here are the details to build your tabs in `tabs` parameter.

```
$element = TabUtils::init('tabs-1', // main tab id
[
	'current' => 'tab1',
	'tabs' => [
		'tab1' => [
			'title' => 'Tabs 1',
			'content' => 'html code...'
		],
		...
	]
]);

```

Array keys are used for menu element id. Values are in a sub-array.

- `icon`: image or icon to be displayed in menu item. Html code. Default: unset or empty.
- `title`: **mandatory** element text. If icon is set, title is displayed on mouse hover.
- `content`: tab content in HTML.
- `view` : if content is not set, path of blade template that must be displayed in tab, e.g. `tabs.editors`.
- `viewparams`: array of key-values to be passed to blade template set in `view` parameter.

Usage
-----

[](#usage-2)

In your controller, pass result to a variable:

`$tabs = TabUtils::init('myid', [...]);`

If `current` parameter is not defined in parameters, you can use this method:

`$tabs->setCurrent('myid')`

Then pass this variable to a view:

```
return view('mybladetemplate', [
		'tabs' => $tabs
]);

```

And in your Blade template, insert your variable at the appropriate line:

`{!! $tabs !!}`

A page can have several tabs sets. In this case, assign each tab set to a different variable.

###  Health Score

48

—

FairBetter than 93% of packages

Maintenance93

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~179 days

Recently: every ~290 days

Total

9

Last Release

33d ago

Major Versions

1.0.3 → 2.0.02022-07-29

PHP version history (3 changes)1.0.1PHP &gt;=5.6

2.2.0PHP &gt;=8.2

2.4.0PHP &gt;=8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/72663124?v=4)[Sébastien L'haire](/maintainers/seblhaire)[@seblhaire](https://github.com/seblhaire)

---

Top Contributors

[![seblhaire](https://avatars.githubusercontent.com/u/72663124?v=4)](https://github.com/seblhaire "seblhaire (28 commits)")

### Embed Badge

![Health badge](/badges/seblhaire-menuandtabutils/health.svg)

```
[![Health](https://phpackages.com/badges/seblhaire-menuandtabutils/health.svg)](https://phpackages.com/packages/seblhaire-menuandtabutils)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[zidbih/laravel-deadlock

Make temporary Laravel workarounds expire and fail CI when ignored.

985.4k](/packages/zidbih-laravel-deadlock)[erlandmuchasaj/laravel-gzip

Gzip your responses.

40146.5k2](/packages/erlandmuchasaj-laravel-gzip)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
