MenuItem Hover / Mouseover Event

UI Components for Angular
Post Reply
Posts: 1
Joined: 02 Mar 2023, 09:06

02 Mar 2023, 09:15

I am trying to call a method (to change the site stylesheet) on mouseover of a menuItem.

Works fine for click events using the command() approach.

Code: Select all

{label: 'Vela Blue', icon: 'pi pi-fw pi-bars', command: () => {this.changeTheme('vela-blue')}},
Is there a way to listen to the hover event rather than the click event on the MenuItem?


Posts: 5
Joined: 03 Mar 2023, 12:06

09 Mar 2023, 12:22

I have also try call a method "to change site style sheet" on mouse over of a menultem.
Can you find some proper way?.


Posts: 5
Joined: 03 Mar 2023, 12:06

13 Mar 2023, 11:01

Hello, esonica
I was found way of solution.. see below....

Yes, you can use the "onMouseEnter" event to listen to the hover event of the MenuItem. You can add the "onMouseEnter" property to your MenuItem and set it to a function that calls your desired method. Here's an example code snippet:

{label: 'Vela Blue', icon: 'pi pi-fw pi-bars', onMouseEnter: () => {this.changeTheme('vela-blue')}}

This will call the "changeTheme" method when the MenuItem is hovered over.

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 11 guests