Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Active Menu Laravel Package

juy/active-menu

Laravel helper to add an “active” CSS class based on the current route name. Supports exact, wildcard, and multiple route patterns via facade, container, or helper, plus a Blade directive. Configurable active class value.

View on GitHub
Deep Wiki
Context7

Active Menu Laravel Package

Latest Version on Packagist Software License

Helper class for Laravel applications to get active class base on current route name (It's only detect "route name, this is enough for us.").


Supported/Tested Laravel versions

  • Laravel 5.1 | 5.2 | 5.3 | 5.4

Requirements

  • Laravel >= 5.1 : Laravel 5.1 or above.
  • PHP >= 5.5.9 : PHP 5.5.9 or above on your machine.

Installation

Step:1 Install through composer

Install

➜ composer require juy/active-menu

Manual install (alternative)

Simply add the following to the "require" section of your composer.json file, and run composer update command.

"juy/active-menu": "^1.1"

Remove

➜ composer remove juy/active-menu

Step 2: Add the service provider

Append this line to your service providers array in config/app.php.

Juy\ActiveMenu\ServiceProvider::class,

Step 3: Publish config

Publish config file.

➜ php artisan vendor:publish --provider="Juy\ActiveMenu\ServiceProvider" --tag="config"

Config overview

You can modify css active class with custom one (default is 'active') in config/activemenu.php (after publish).

return [

    // The default css class value if the request match given route name
    'class' => 'active',

];

Usage, samples

Alias/Facade

Active::route('route.name');

Application container

app('active')->route('route.name');

Helper function

active_route('route.name');

Wildcard samples

Active::route('route.name.*');
active_route('route.name.*');

Multi route with wilcard

Active::route(['route.name1.*', 'route.name2.*']);
active_route(['route.name1.*', 'route.name2.*']);

Custom blade directive

@ifActiveRoute('route.name')
    <p>Foo</p>
@else
    <p>Bar</p>
@endif

Real life usage

<li class="item {{ active_route('admin.index') }}">
    <a href="admin/index">Dashboard</a>
</li>

License

This project is open-sourced software licensed under the MIT License.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge