Metronic

The World’s #1 Bootstrap 4 HTML, Angular 8, React & VueJS

Admin Dashboard Theme Framework

Menu

Overview

KTMenu is a Metronic's custom plugin defined in [metronic]/theme/default/[demo]/src/assets/js/global/components/base/menu.js.

The Metronic's Menu components allows to manage both horizontal and vertical multi level menus for both desktop and mobile modes.

Initialization

The below code shows the basic vertical menu initialization with accordion submenu mode:

var asideMenu = new KTMenu(id, options);
var asideMenu = new KTMenu('kt_aside_menu', {
    // vertical scroll
    scroll: {
        height: function() {}
    },

    // submenu setup
    submenu: {
        desktop: {
            // by default the menu mode set to accordion in desktop mode
            default: 'accordion',
            // whenever body has this class switch the menu mode to dropdown
            state: {
                body: 'kt-aside--minimize',
                mode: 'dropdown'
            }
        },
        tablet: 'accordion', // menu set to accordion in tablet mode
        mobile: 'accordion' // menu set to accordion in mobile mode
    },

    //accordion setup
    accordion: {
        expandAll: false // allow having multiple expanded accordions in the menu
    }
});

The below code shows the basic horizontal menu initialization:

var headerMenu = new KTMenu('kt_header_menu', {
    submenu: {
        desktop: 'dropdown',
        tablet: 'accordion',
        mobile: 'accordion'
    },
    accordion: {
        slideSpeed: 200, // accordion toggle slide speed in milliseconds
        expandAll: false // allow having multiple expanded accordions in the menu
    }
});

Options

Field Type Description
accordion.slideSpeed number

Accordion toggle slide speed in milliseconds

Sample
accordion: {
    slideSpeed: 200
},
accordion.autoScroll boolean

Enable auto scrolling(focus) to the clicked menu item

Sample
accordion: {
    autoScroll: true
},
accordion.autoScrollSpeed number

Enable auto scrolling(focus) to the clicked menu item

Sample
accordion: {
    autoScrollSpeed: 1200
},
accordion.expandAll boolean

Allow having multiple expanded accordions in the menu

Sample
accordion: {
    expandAll: true
},
dropdown.timeout number

Timeout in milliseconds to show and hide the hoverable submenu dropdown

Sample
dropdown: {
    timeout: 500
},
submenu.desktop object|string

Submenu setup for desktop. Set default for the menu mode in desktop mode. Whenever any element in HTML has desktop.state.body class switch the menu mode to desktop.state.mode

In the sample below scenario. By default the menu mode set to accordion in desktop mode. Whenever body tag has this class switch the menu mode to dropdown

Sample
submenu: {
    desktop: {
        default: 'accordion',
        state: {
            body: 'kt-aside--minimize',
            mode: 'dropdown'
        }
    },
},

Events

Method Description
linkClick

Fired on links(non submenu toggle link) click.

asideMenu.on('linkClick', function(target, e){
  alert(target.tagName); // link element tag name
  alert(e.type); // event type
  //e.preventDefault();  // default event prevent
  //return false; // return false to cancel link click
});
Input Parameters
Name Type Description
target object Link target element.
event object Default event object.
submenuToggle

Fired after submenu accordion toggle.

asideMenu.on('submenuToggle', function(target, e){
  alert(target.tagName); // submenu element tag name
  alert(e.type); // event type
});
Input Parameters
Name Type Description
target object Link target element.
event object Default event object.

API Methods

Method Description
setDefaults(options)

Set default options

Input Parameters
Name Type Description
options object

A new options object for the menu

setActiveItem(item)

Set active menu item

Input Parameters
Name Type Description
item HTML object

Menu item HTML element object

getBreadcrumbs(item)

Get breadcrumb for menu item

Input Parameters
Name Type Description
item HTML object

Menu item HTML element object

getPageTitle(item)

Get page title for menu item

Input Parameters
Name Type Description
item HTML object

Menu item HTML element object

hideDropdown(item)

Hide dropdown submenu item

Input Parameters
Name Type Description
item HTML object

Menu item HTML element object

pauseDropdownHover(item)

Disable menu for given time

Input Parameters
Name Type Description
item HTML object

Menu item HTML element object

resumeDropdownHover(item)

Enable menu item back after being paused

Input Parameters
Name Type Description
item HTML object

Menu item HTML element object

getSubmenuMode()

Get submenu mode

reload()

Reload the menu

on(name, handler)

Register event

Input Parameters
Name Type Description
name string

Unique event name

handler function

Callback function handler for the event

one(name, handler)

Register event to be run once

Input Parameters
Name Type Description
name string

Unique event name

handler function

Callback function handler for the event

I run a team of 20 product managers, developers, QA and UX resources. Previously we designed everything ourselves. For our newest platform we tried out Metronic. I cannot overestimate the impact Metronic has had. It's accelerated development 3x and reduced QA issues by 50%. If you add up the reduced need for design time/resources, the increase in dev speed and the reduction in QA, it's probably saved us $100,000 on this project alone, and I plan to use it for all platforms moving forward.
The flexibility of the design has also allowed us to put out a better looking & working platform and reduced my headaches by 90%. Thank you KeenThemes! Jonathan Bartlett, Metronic Customer

Powerful Framework

Everything within Metronic is customizable globally to provide limitless unique styled projects

Multi Demo

Choose a perfect design for your next project among hundreds of demos

Limitless Components

A huge collection of components to power your application with the latest UI/UX trands

Angular 8 & React Support

Enterprise ready Angular and React integration with built-in authentication module and many more

Bootstrap 4

Metronic deeply customizes Bootstrap with native look and feel

Exclusive Datatable Plugin

Our super sleek and intuitive Datatable comes packed with all advanced CRUD features

75,000+ Strong

Metronic is the only theme trusted by over 70,000 developers world wide

Continuous Updates

Lifetime updates with new demos and features is guaranteed

Quality Code

Metronic is written with a code structure that all developers will be able to pick up easily and fall in love

The Ultimate Bootstrap Admin Theme Trusted By Over 70,000 Developers World Wide