Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
N

ng-material-multilevel-menu

> 前端框架
Open source

:page_facing_up: Material Multi-Level Menu for Angular Projects

99 stars0 likes2 views
WebsiteGitHub

About

:page_facing_up: Material Multi-Level Menu for Angular Projects

ng-material-multilevel-menu

Material Multi-Level Menu for Angular Projects.

Why ng-material-multilevel-menu?

The main goal of this package is to deliver a slim and Skinny Material Multi-Level Menu for Angular Projects. That can fit into any kind of projects with no muss, no fuss. Within few lines, you will get an animation ready multilevel list that just works.

Demo

Check the Material Multi-Level Menu in action, click here.

Features

  1. Material Icons are supported.
  2. FontAwesome Icons are supported.
  3. Use images as icons in the list.
  4. Seamlessly work with Angular routing, if provided.
  5. RTL supported (thanks to StavM).
  6. Supports Custom List Templates
    1. Demos
    2. Documentation

Installation

You can use either the npm or yarn command-line tool to install packages. Use whichever is appropriate for your project in the examples below.

NPM

bash
npm install --save ng-material-multilevel-menu

YARN

bash
yarn add --save ng-material-multilevel-menu

Usage

Follow below steps to add multi level list in your project

1. Import NgMaterialMultilevelMenuModule

You need to import the NgMaterialMultilevelMenuModule in the module of your app where you want to use it.

typescript
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

/* Import the module*/
import { NgMaterialMultilevelMenuModule } from 'ng-material-multilevel-menu';

import { AppComponent } from './app.component';

@NgModule({
    declarations: [
    AppComponent
    ],
    imports: [
    BrowserModule,
    NgMaterialMultilevelMenuModule // Import here
    ],
    providers: [],
    bootstrap: [AppComponent]
})
export class AppModule { }

2. Use in your HTML

In your HTML: Use the `````` wherever you like in your project.

xml

3. Structure of array to display the list

Make sure you structure of array should look like array shown below,

…

API

  • Using configuration, You can customise the appearance of the list.
    • paddingAtStart: boolean => [optional] If you don't want padding at the start of the list item, then you can give false. The default value will be true.
    • interfaceWithRoute: boolean => [required] only if you want to use Angular Routing with this menu.
    • highlightOnSelect: boolean => [optional] If you want to highlight the clicked item in the list, then you can do that by making it true. The default value will be false.
    • useDividers: boolean => [optional] If you want to the list to have dividers. The default value will be true.
    • collapseOnSelect: boolean; => [optional] You have the option to collapse another parent when clicked on the current parent. The default value will be false.
    • rtlLayout: boolean; => [optional] whether display is Right To Left. The default value will be false.
    • classname: string; => [optional] You can give your own custom class name in order to modify the list appearance.
    • listBackgroundColor: string; => [optional] You can apply custom color to the background of the list.
    • fontColor: string; => [optional] Changes the color of Text and icons inside the list.
    • backgroundColor: string; => [optional] This will change the background color list container.
    • selectedListFontColor: string; => [optional] This will change the font color of selected list item.

Below is example how you can apply different background and Font colors,

typescript
config = {
    paddingAtStart: true,
    interfaceWithRoute: true,
    classname: 'my-custom-class',
    listBackgroundColor: `rgb(208, 241, 239)`,
    fontColor: `rgb(8, 54, 71)`,
    backgroundColor: `rgb(208, 241, 239)`,
    selectedListFontColor: `red`,
    highlightOnSelect: true,
    collapseOnSelect: true,
    useDividers: false,
    rtlLayout: false
};

Misc

1. Exapand/ Collapse all Menu

You can expand all the menu and Collapse all the menus. Below is example how you can do that,

typescript
import { MultilevelMenuService, ExpandCollapseStatusEnum } from 'ng-material-multilevel-menu';

export class AppComponent {
    constructor(
        private multilevelMenuService: MultilevelMenuService
    ) {}

    setExpandCollapseStatus(type: ExpandCollapseStatusEnum) {
        this.multilevelMenuService.setMenuExapandCollpaseStatus(type);
    }
}

2. Select Menu By ID

You can expand all the menu and Collapse all the menus. Below is example how you can do that,

typescript
import { MultilevelMenuService, MultilevelNodes } from 'ng-material-multilevel-menu';

export class AppComponent {
    menuWithID: MultilevelNodes[] = null

    constructor(
        private multilevelMenuService: MultilevelMenuService
    ) {}

    menuIsReady(menus: MultilevelNodes[]) {
        this.menuWithID = menus;
    }

    selectMenuID(MenuID){
        this.multilevelMenuService.selectMenuByID(MenuID);
    }

}

3. Building Custom Templates

In this section, you will find useful information if you are planning to write your own templates.

  1. First and very important is MultilevelNodes interface, every menu item implements this interface. Make sure you look into each property of this interface when building custom menu templates. For example properties like isSelected, hasChilden, expanded, disabled, items, label, and so on are extremely helpful, have look into some demos here.
  2. You actually don't have to write Slide-In/ Slide-Out, Arrow Rotation animation. The module exports these animations out of the box, so you can import them and use it as shown below.

demo.component.ts:

typescript
import {SlideInOut, ExpandedRTL, ExpandedLTR } from 'ng-material-multilevel-menu';

@Component({
    selector: 'app-demo',
    templateUrl: './demo.component.html',
    styleUrls: ['./demo.component.css'],
    animations: [
      SlideInOut,
      ExpandedLTR,
      ExpandedRTL,
    ]
})
  1. You have decided to write a custom template, then you have to write the corresponding CSS for the same.
  2. Below is a very simple example of the custom menu templates,

demo.component.html:

xml
 
    
        

                

            
            

        
    

demo.component.ts:

…

demo.component.css:

…

Default classes

  • selected-amml-item: This class will be applied to currently selected link and it's father links.
  • active-amml-item: This class will be applied to currently selected link.

Dependencies

  1. Angular Material

Contribution

I welcome you to fork and add more features into it. If you have any bugs or feature request, please create an issue at github repository.

License

MIT

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScriptangularangular-materialangular-multilevel-listangular-multilevel-menu

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架