How to change title of an ion-icon?
Asked Answered
O

4

11

I'm trying to change the ion-icon title that appears on mouse-hover.
Example: pic
I've tried for at least a couple of hours to find a solution for this. I just don't know how i can access the title element of ion-icon via css to be able to change the content of it to 'Edit' instead of 'Create'. Any help would be appreciated.

Outlander answered 5/3, 2021 at 0:18 Comment(0)
S
10

You may try disabling ion-icon popup using CSS event blocking and set "title" property on to a parent element.

CSS

ion-icon {
 pointer-events: none;
}

Or you can create Icon element using the below code as a workaround and set it on a button.

const icon = <Icon icon='arrow-right' title={false} />;
return <Button minimal icon={icon} title='Next' />;

Details here - https://github.com/palantir/blueprint/issues/2321

Selfoperating answered 5/3, 2021 at 1:59 Comment(0)
M
10

disable events:

ion-icon {
    pointer-events: none;
}

and wrap icon with span tag using title attribute:

<span title="Edit" style="font-size: x-large;">
  <ion-icon name="create"></ion-icon>
</span>
Modiolus answered 7/5, 2021 at 5:39 Comment(2)
I had to add line-height: 0 to the span to avoid icon alignment problems, since my icon was smaller than the default line height. Simple solution, thanks.Steel
You can directly disable events inside the <ion-icon> tag by using style as follows: <ion-icon name="create" style="pointer-events: none;"></ion-icon>Isauraisbel
V
0

Ionic 5 - Just wrap it in a div like below:

<div (click)="presentActionsPopover($event, obj)" slot="end" title="Actions" size="small">
      <ion-icon name="ellipsis-vertical-outline" slot="icon-only"></ion-icon>
    </div>
Vauban answered 26/10, 2021 at 20:12 Comment(0)
V
0

Try the below:

<ion-button title="Create Project">
<ion-icon  name="create"></ion-icon>
</ion-button>
Viscose answered 7/12, 2021 at 6:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.