The purpose of the project is to create reusable multilevel menu.
npm install @ezetech/react-multi-level-menu-component --save
import MenuList from '@ezetech/react-multi-level-menu-component';
Basic use of the MultilevelMenu can be described with:
<MenuList
listClass="context-menu"
itemClass="context-menu-item"
triangleClassName="context-menu-item-triangle"
position={{ top: 50, left: 40 }}
clickItemCallback={this.clickItemCallback}
show
items={items}
/>Css class which will be applied to list container in menu
Css class which will be applied to item of menu list
Css class which will be applied to svg triangle within nested menu item
Takes an object with to parameteres: top and left. Will be used to position menu on the page.
Function which will be called when not a nested item will be clicked. Each click callback receives item name.
Number of miliseconds which specifies a delay for closing nested menu.
Boolean which controls whether a menu should be shown.
An array of items with next structure:
var items = [
{
text: 'Item 1',
name: 'item-1'
},
{
text: 'Item 2',
name: 'item-2',
items: [{
name: 'sub-item-21',
text: 'SubItem 21'
}
}
];Where text will be used for visual representation of item and name will be passed to each clickCallback function.
Any item may have it's own items parameter, they will be rendered as a nested menu for an item.