Skip to main content

Command Palette

Search for a command to run...

Styling active route menu item in laravel

Updated
•1 min read•View as Markdown
Styling active route menu item in laravel

You can check if the current route is active just with

request()->routeIs('admin.cities')

Or even sub-routes (like editing, creating, or whatever with

request()->routeIs('admin.cities*')

If you prefer to use the route facade, you still can do that with

Route::named('admin.cities*')

By using the * character, you can apply the active class to submenus easily:

routeIs('admin.cities*') ? 'active' : '' }}"> Cities
routeIs('admin.cities.index') ? 'active' : '' }}><a>List</a>
routeIs('admin.cities.create') ? 'active' : '' }}><a>Create</a>