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

pawled free asked 2 years ago


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


free answered 1 year ago


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



Dawid Wajszczuk staff answered 2 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 free commented 2 years ago

I meant navbar dropdown rather.


Mateusz Lazaru staff commented 2 years ago

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


cloudsyte2 premium answered 2 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.



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

  • ForumUser: 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