Default vertical menu is full width. You may want change that behavior and make the menu compact at page level or at template level. You can experience compact menu in left side menu.
This table contains all classes related to the vertical fixed navigation option.
All these options can be set via following classes:
Classes | Description |
---|---|
.menu-collapsed |
To create vertical compact menu, you need to add .menu-collapsed class in <body> tag. Refer HTML markup line no 4. |
This section contains HTML Markup to create vertical compact menu. It define where to add css classes to make vertical compact menu.
.menu-collapsed
class to set vertical compact menu.
<!DOCTYPE html>
<html lang="en">
<head></head>
<body data-menu="vertical-menu" class="vertical-layout vertical-menu 2-column menu-collapsed">
<!-- fixed-top-->
<nav role="navigation" class="header-navbar navbar-expand-sm navbar navbar-with-menu fixed-top navbar-dark navbar-shadow navbar-border">
...
</nav>
<!-- BEGIN Navigation-->
<div class="main-menu menu-dark menu-fixed menu-shadow">
...
</div>
<!-- END Navigation-->
<!-- BEGIN Content-->
<div class="content app-content">
<div class="content-wrapper">
<!-- content header-->
<div class="content-header row">
...
</div>
<!-- content header-->
<!-- content body-->
<div class="content-body">
...
</div>
<!-- content body-->
</div>
</div>
<!-- END Content-->
<!-- START FOOTER DARK-->
<footer class="footer footer-dark">
...
</footer>
<!-- START FOOTER DARK-->
</body>
</html>
Modern Admin use PUG as template engine to generate pages and whole template quickly using node js, for getting start with PUG usage & template generating process please refer template documentation.
This table contains required PUG variables to generate vertical compact menu.
Block | Variable | Datatype | Value | Description |
---|---|---|---|---|
verticalMenuConfig |
menuCollapsed |
boolean |
true |
verticalMenuConfig block has a menuCollapsed variable, You need to set that variable to true to enable compact menu at template level.
|
Use following PUG code to generate page or template having vertical compact menu.
menuCollapsed
variable value as true
in verticalMenuConfig
block.If you want to use vertical compact menu options on page level you need to define it on page it self. This template has one example pug file for vertical-nav-compact-menu.pug
, however you can use it on template level but it will generate whole template have vertical fixed navigation.
extends ../base
//- Template customization
//------------------------
block templateConfig
- var templateCustom = "vertical-layout vertical-menu-modern"
- var dataMenu = "vertical-menu-modern"
//- Page level customization
//------------------------
block pageConfig
- var logoType = 'light'
block navbarConfig
- var navbarPosition = "fixed-top"
- var navbarColor = "navbar-semi-dark"
- var navbarShadow = true
block verticalMenuConfig
- var menuType = "menu-fixed"
- var menuColor = "menu-dark"
- var menuOpenType = "menu-accordion"
- var menuShadow = true
- var menuCollapsed = true
block footerConfig
- var footerType = "footer-static"
- var footerColor = "footer-light"
- var footerBorder = true
This section contains JavaScript code to enable compact menu at page level only. You must include following js code in a custom javascript file and must include on that page only where compact menu is required.
$.app.menu.collapse();
This section contains JavaScript code to enable compact menu at template level. You must set the compactMenu variable to "true" in the app.js file found at this page "app-assets/js/core/app.js". We have already added that code in app.js file where you can just change false to true.
var compactMenu = true;