Bob.Tern
Posts: 15
Joined: Wed Nov 15, 2023 7:02 am

Adding a class change on a mouseover

Hi, I am wondering how I can add a class change on a mouseover event in a *nfFor list. Ive tried lots of different ways, and learned alot about the structure of the appery system, but never actually found a method that worked. Basically, I want the list item to HIGHLIGHT when the mouseover is happening. Any method to make that happen would be fine. Thank you.
aantsypau
Posts: 29
Joined: Wed May 24, 2023 7:57 am

Re: Adding a class change on a mouseover

In an Ionic app, to apply a CSS class to a list item when you hover (mouse over) it, you can use standard CSS with the :hover pseudo-class.

1. HTML (Ionic list item)
2. CSS (global or component style)
.hoverable-item:hover {
--ion-item-background: #ddd;
cursor: pointer;
}
Notes:
Works well in desktop environments (like in browsers or PWA desktop mode).

On mobile devices, :hover doesn't apply — consider using ion-gesture, click events, or [class.active] logic for touch interactions instead.
Attachments
unnamed (2).png
unnamed (2).png (59.58 KiB) Viewed 5696 times
unnamed (1).png
unnamed (1).png (40.95 KiB) Viewed 5696 times
unnamed.png
unnamed.png (191.19 KiB) Viewed 5696 times

Return to “Issues”