Dynamically add 'active' prop in MDB Bootstrap Rea

Topic: Dynamically add 'active' prop in MDB Bootstrap React Navbar

Raghav Sharma asked 2 years ago

Expected behavior

How do I add the active class dyanmically i.e send via prop in mdbootstrap react navbar?

I want it to change as soon as I click on a <MDBNavitem>

<MDBNavItem active>
          <MDBNavLink to="#!">Home</MDBNavLink>

Resources (screenshots, code snippets etc.)


Piotr Glejzer staff commented 2 years ago

You can change active with a state with conditions.

<MDBNavItem active={yourState? true : false } />

Please insert min. 20 characters.


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



Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: MDB React
  • MDB Version: 4.26.1
  • Device: Macbook
  • Browser: Google Chrome
  • OS: Mac OS Catalina
  • Provided sample code: No
  • Provided link: Yes