Skip to content

reference

Mathieu Maes edited this page May 15, 2018 · 1 revision

Table of contents

Menu

Part of @node-menu/core

const menu = new Menu("TopMenu", { ... });

Defines the root element of a menu, generally rendered as a <nav> element in HTML.

new Menu(name, [options])

name Provide a name for the name

Options

children An array of objects or MenuItem instances to be used as menu items . The objects will be passed as options to the addChild method. You must also provide the label attribute in the object.

Menu.addChild(label, [options])

Adds a single submenu item. See MenuItem for options reference. Returns the newly created MenuItem instance.

MenuItem

This object represents a menu item, generally rendered as a <li><a>...</a></li> in HTML. It's API is very similar to Menu though.

new MenuItem(label, [options])

label Label of the menu, which is generally used as the visible text of the menu item

options

href Link of the menu item

isCurrent boolean set to true when the item must have an active/current state

parent Reference to the parent Menu or MenuItem

children Array of instances of MenuItem or objects similar to the addChild options including the label property.

menuItem.addChild(label, [options])

Adds a submenu and -if needed- creates an instance of MenuItem. label and options are equal to the MenuItem constructor arguments.

Clone this wiki locally