Skip to main content
/
/
/
useNav()

useNav()

import useNav from "@intility/bifrost-react/hooks/useNav";

The useNav hook returns an object with state accessors for the side and mobile menus. It has to be used from a descendant of the <Nav> component.

  • bool sideCollapsed is true when sidebar is collapsed (even if hidden for small screens)
  • function setSideCollapsed(bool) provides your own mechanism for persisting collapse/expand sidebar state
    • NOTE: function will be undefined if not provided
  • bool mobileOpen is true when mobile nav is open (even if hidden for large screens)
  • function setMobileOpen(bool) shows/hides the mobile nav (will still be hidden for large screens)
  • bool isMobile is true when mobile hamburger menu button is displayed and sidebar is hidden avoid for SSR/SSG/Unit testing (depends on window.matchMedia)

Try resizing your window to test the mobile part of the demo.