Menu is a navigation/command component that supports dynamic and static positioning.
import { Menu } from 'primereact/menu';
<script src="https://unpkg.com/primereact/core/core.min.js"></script>
<script src="https://unpkg.com/primereact/menu/menu.min.js"></script>
Menu uses the common menumodel api to define its items, visit MenuModel API for details.
Menu requires a collection of menuitems as its model.
<Menu model={items} />
let items = [
{label: 'New', icon: 'pi pi-fw pi-plus'},
{label: 'Delete', icon: 'pi pi-fw pi-trash'}
];
Menu supports one level of nesting via subitems of an item.
let items = [
{
label: 'Options',
items: [{label: 'New', icon: 'pi pi-fw pi-plus',command:()=>{ window.location.hash="/fileupload"; }},
{label: 'Delete', icon: 'pi pi-fw pi-trash', url: 'http://primetek.com.tr'}]
},
{
label: 'Account',
items: [{label: 'Options', icon: 'pi pi-fw pi-cog',command:()=>{ window.location.hash="/"; }},
{label: 'Sign Out', icon: 'pi pi-fw pi-power-off'} ]
}
]
Menu is inline by default whereas popup mode is supported by enabling popup property and calling toggle method with an event of the target.
<Menu model={items} popup ref={menu} />
<Button label="Show" icon="pi pi-bars" onClick={(event) => menu.current.toggle(event)}/>
Name | Type | Default | Description |
---|---|---|---|
id | string | null | Unique identifier of the element. |
model | array | null | An array of menuitems. |
popup | boolean | false | Defines if menu would displayed as a popup. |
style | string | null | Inline style of the component. |
className | string | null | Style class of the component. |
baseZIndex | number | 0 | Base zIndex value to use in layering. |
autoZIndex | boolean | true | Whether to automatically manage layering. |
appendTo | DOM element | string | document.body | DOM element instance where the overlay panel should be mounted. Valid values are any DOM Element and 'self'. The self value is used to render a component where it is located. |
transitionOptions | object | null | The properties of CSSTransition can be customized, except for "nodeRef" and "in" properties. |
Name | Parameters | Description |
---|---|---|
toggle | event: Browser event | Toggles the visibility of the popup menu. |
show | event: Browser event | Displays the popup menu. |
hide | event: Browser event | Hides the popup menu. |
Name | Parameters | Description |
---|---|---|
onShow | event: Browser event | Callback to invoke when a popup menu is shown. |
onHide | event: Browser event | Callback to invoke when a popup menu is hidden. |
Following is the list of structural style classes, for theming classes visit theming page.
Name | Element |
---|---|
p-menu | Container element. |
p-menu-list | List element. |
p-menuitem | Menuitem element. |
p-menuitem-text | Label of a menuitem. |
p-menuitem-icon | Icon of a menuitem. |
This section is under development. After the necessary tests and improvements are made, it will be shared with the users as soon as possible.
None.
Built-in component themes created by the PrimeReact Theme Designer.
Premium themes are only available exclusively for PrimeReact Theme Designer subscribers and therefore not included in PrimeReact core.
Beautifully crafted premium create-react-app application templates by the PrimeTek design team.