How to make a navbar dropdown-link active automatically?


Topic: How to make a navbar dropdown-link active automatically?

pawled asked 3 years ago

I wanna make dropdown-link active when any of its items is on. Same as in sidenav-link with collapsible content.


cloudsyte2 pro premium answered 3 years ago

This might help https://stackoverflow.com/questions/42941245/navbar-css-automatic-add-active-in-dropdown-menu

Change the code according to your framework (js/react).

Also, what you need to do in a nutshell is, watch for the URL (window.location) and see if it is equal to your dropdown link route.


Dawid Wajszczuk staff answered 3 years ago

Hi,

What @cloudsyte2 sent will get the job done. Here is the snippet with possible solution for MDB https://mdbootstrap.com/snippets/standard/d-wajszczuk/3768473.

Keep coding,
Dawid


pawled commented 2 years ago

I meant navbar dropdown rather.


mlazaru staff commented 2 years ago

It does not have such option. We will consider adding it in future.


Bellmare answered 2 years ago

If you want your navbar dropdown-link to be active automatically, you can use the "active" class.


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: MDB Standard
  • MDB Version: MDB5 3.11.0
  • Device: Any
  • Browser: Any
  • OS: Any
  • Provided sample code: No
  • Provided link: No