Add 2 different method to lable and icon in Primereact Menu

UI Components for React
Post Reply
sanjaybharekar
Posts: 1
Joined: 19 Mar 2021, 08:49

19 Mar 2021, 09:21

Hello Team,

I am using our primereact menu and i have to set to different methods to my label and my icon.

currently, we can apply only one method to both. Can you please help me in this.

mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

06 May 2021, 15:33

Hello,

I think you can use template option to custom menu items. Please see;
https://primefaces.org/primereact/showcase/#/menumodel

Code: Select all

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


Best Regards,

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 19 guests