lara-light-indigo

MenuModel API

PrimeReact menus components share a common api to specify the menuitems and submenus.

MenuItem

Core of the API is the MenuItem class that defines various options such as the label, icon and children of an item in a menu.


const 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'} ]
    }
]

 

MenuItem provides the following properties. Note that not all of them may be utilized by the corresponding menu component.

NameTypeDefaultDescription
labelstringnullText of the item.
iconstringnullIcon of the item.
commandfunctionnullCallback to execute when item is clicked.
urlstringnullExternal link to navigate when item is clicked.
itemsarraynullAn array of children menuitems.
expandedbooleanfalseVisibility of submenu.
disabledbooleanfalseWhen set as true, disables the menuitem.
targetstringnullSpecifies where to open the linked document.
separatorbooleanfalseDefines the item as a separator.
styleobjectnullInline style of the menuitem.
classNamestringnullStyle class of the menuitem.
templateanynullTemplate of the menuitem.

Template

Used to create custom menuitem elements.


const items =
[
    {
        label: 'New',
        template: (item, options) => {
            return (
                /* custom element */
                <a className={options.className} target={item.target} onClick={options.onClick}>
                    <span className={classNames(options.iconClassName, 'pi pi-home')}></span>;
                    <span className={options.labelClassName}>{item.label}</span>;
                </a>
            );
        }
    }
];

 

template: (item, options) => {
    // item: Current item object.
    // options.onClick: Click event for the default element.
    // options.className: Style class of the default element.
    // options.labelClassName: Style class of the default label element.
    // options.iconClassName: Style class of the default icon element.
    // options.element: Default element created by the component.
    // options.props: component props.

    // Note: Extra options may come according to the components.
}
 

Command

The function to invoke when an item is clicked is defined using the command property.


const items =
[
    {
        label: 'New',
        icon: 'pi pi-plus',
        command: (event) => {
            // event.originalEvent: Browser event
            // event.item: MenuItem instance
        }
    }
];

 

Navigation

Navigation is specified using url property for external links or using command function for internal router.


const items =
[
    {
        label: 'New',
        icon: 'pi pi-plus',
        command: (event) => {
            window.location.hash = "/fileupload";
        }
    },
    {
        label: 'Link',
        icon: 'pi pi-check',
        url: 'https://www.primefaces.org/primereact'
    }
];

 

Component Scale

Input Style

Ripple Effect

Free Themes

Built-in component themes created by the PrimeReact Theme Designer.

Bootstrap
Blue
Purple
Blue
Purple
Material Design
Indigo
Deep Purple
Indigo
Deep Purple
Material Design Compact
Indigo
Deep Purple
Indigo
Deep Purple
Tailwind
Tailwind Light
Fluent UI
Blue
PrimeOne Design - 2022 NEW
Lara Indigo
Lara Blue
Lara Purple
Lara Teal
Lara Indigo
Lara Blue
Lara Purple
Lara Teal
PrimeOne Design - 2021
Saga Blue
Saga Green
Saga Orange
Saga Purple
Vela Blue
Vela Green
Vela Orange
Vela Purple
Arya Blue
Arya Green
Arya Orange
Arya Purple
Premium Themes

Premium themes are only available exclusively for PrimeReact Theme Designer subscribers and therefore not included in PrimeReact core.

Soho Light
Soho Dark
Viva Light
Viva Dark
Mira
Nano

Legacy Free Themes

Nova
Nova Alt
Nova Accent
Luna Blue
Luna Green
Luna Amber
Luna Pink
Rhea

Premium Create-React-App Templates

Beautifully crafted premium create-react-app application templates by the PrimeTek design team.

Sakai
Atlantis
Freya
Ultima
Diamond
Sapphire
Serenity
Babylon
Avalon
Apollo
Roma