import {PanelMenuModule} from 'primeng/panelmenu';
import {MenuItem} from 'primeng/api';
PanelMenu uses the common menumodel api to define its items, visit MenuModel API for details.
PanelMenu requires nested menuitems as its model.
<p-panelMenu [model]="items" [style]="{'width':'300px'}"></p-panelMenu>
export class PanelMenuDemo {
items: MenuItem[];
ngOnInit() {
this.items = [
{
label: 'File',
icon: 'fa-file-o',
items: [{
label: 'New',
icon: 'fa-plus',
items: [
{label: 'Project'},
{label: 'Other'},
]
},
{label: 'Open'},
{label: 'Quit'}
]
},
{
label: 'Edit',
icon: 'fa-edit',
items: [
{label: 'Undo', icon: 'fa-mail-forward'},
{label: 'Redo', icon: 'fa-mail-reply'}
]
},
{
label: 'Help',
icon: 'fa-question',
items: [
{
label: 'Contents'
},
{
label: 'Search',
icon: 'fa-search',
items: [
{
label: 'Text',
items: [
{
label: 'Workspace'
}
]
},
{
label: 'File'
}
]}
]
},
{
label: 'Actions',
icon: 'fa-gear',
items: [
{
label: 'Edit',
icon: 'fa-refresh',
items: [
{label: 'Save', icon: 'fa-save'},
{label: 'Update', icon: 'fa-save'},
]
},
{
label: 'Other',
icon: 'fa-phone',
items: [
{label: 'Delete', icon: 'fa-minus'}
]
}
]
}
];
}
}
MenuItem has an expanded property to control the visibility of a submenu, you may use this property to control the state from the menumodel.
| Name | Type | Default | Description |
|---|---|---|---|
| model | array | null | An array of menuitems. |
| style | string | null | Inline style of the component. |
| styleClass | string | null | Style class of the component. |
| multiple | boolean | true | Whether multiple tabs can be activated at the same time or not. |
Following is the list of structural style classes, for theming classes visit theming page.
| Name | Element |
|---|---|
| ui-panelmenu | Container element. |
| ui-panelmenu-header | Accordion header of root submenu. |
| ui-panelmenu-content | Accordion content of root submenu. |
| ui-menu-list | List element. |
| ui-menuitem | Menuitem element. |
| ui-menuitem-text | Label of a menuitem. |
| ui-menuitem-icon | Icon of a menuitem. |
| ui-panelmenu-icon | Arrow icon of an accordion header. |
None.
<p-panelMenu [model]="items" [style]="{'width':'300px'}"></p-panelMenu>
export class PanelMenuDemo {
items: MenuItem[];
ngOnInit() {
this.items = [
{
label: 'File',
icon: 'fa-file-o',
items: [{
label: 'New',
icon: 'fa-plus',
items: [
{label: 'Project', icon: 'fa-lock'},
{label: 'Other', icon: 'fa-list'}
]
},
{label: 'Open', icon: 'fa-external-link'},
{separator: true},
{label: 'Quit', icon: 'fa-close'}
]
},
{
label: 'Edit',
icon: 'fa-edit',
items: [
{label: 'Undo', icon: 'fa-mail-forward'},
{label: 'Redo', icon: 'fa-mail-reply'}
]
},
{
label: 'Help',
icon: 'fa-question',
items: [
{
label: 'Contents',
icon: 'fa-bars'
},
{
label: 'Search',
icon: 'fa-search',
items: [
{
label: 'Text',
items: [
{
label: 'Workspace'
}
]
},
{
label: 'File',
icon: 'fa-file',
}
]}
]
},
{
label: 'Actions',
icon: 'fa-gear',
items: [
{
label: 'Edit',
icon: 'fa-refresh',
items: [
{label: 'Save', icon: 'fa-save'},
{label: 'Update', icon: 'fa-save'},
]
},
{
label: 'Other',
icon: 'fa-phone',
items: [
{label: 'Delete', icon: 'fa-minus'}
]
}
]
}
];
}
}