Topic: Sidenav to Navbar on breakpoint

Lewis priority asked 2 years ago

When on a xl + device, I would like a static Sidenav to the left but when moving to a device with a smaller viewport, I would like it to change to a navbar with a button to make the sidenav flyout over the content. Is there a native way to do this?

Also, on the examples of sidenav, I don't seem to be able to put content into the main window without it overlapping the sidenav. Maybe I am missing something?

Dawid Wajszczuk staff commented 2 years ago

  1. Do you mean something like this?

  2. I'm not sure if this is what you are referring to, but maybe you need to add left padding as in the example above or change sidenav's position following this example:

Lewis priority commented 2 years ago

Thanks Dawid, this is what I am after. Just missed it when looking through the examples. Only thing I can't get working is the toggler Sidenav:


Javascript:// Global menu changerconst sidenav = document.getElementById('sidenav');const instance = mdb.Sidenav.getInstance(sidenav);

let innerWidth = null;

const setMode = (e) => { // Check necessary for Android devices if (window.innerWidth === innerWidth) { return; }

innerWidth = window.innerWidth;

if (window.innerWidth < 660) {
} else {



// Event listeners

window.addEventListener('resize', setMode);

Dawid Wajszczuk staff commented 2 years ago

Works fine in this snippet that I have created: Maybe there is some typo or wrong id. Copy & paste code from my snippet and see if it works.

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

  • ForumUser: Priority
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 3.9.0
  • Device: Laptop
  • Browser: Edge
  • OS: W10
  • Provided sample code: No
  • Provided link: No