You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mathieu Maes edited this page May 15, 2018
·
1 revision
Installation
Make sure you have installed the Core package:
npm install @node-menu/core
Creating a menu
After installation, you should start by defining a menu:
const{ Menu, MenuItem }=require("@node-menu/core")consttopMenu=newMenu("topMenu",{children: [{label: "Home",href: "/",},{label: "Our team",href: "/team",children: [{label: "Sales team",href: "/team/sales",}]},{label: "Services",href: "/services",}]});// You can also add menu's by calling Menu::addChildtopMenu.addChild("Contact us",{href: "/contact"});// Or, create your MenuItem instance yourselfconstjobsMenu=newMenuItem("Jobs",{href: "/jobs"});topMenu.addChild(jobsMenu);// This works in an infinite number of levelsconstapplyMenu=jobsMenu.addChild("Apply now",{href: "/jobs/application"});
Note: The root node of your menu is an instance of Menu,
children and other decendants are instances of MenuItem.