I need to set a custom icon to ion-select. Following is my code and output
<ion-item class="input-container" align-items-center no-padding>
<ion-label position="floating" no-margin no-padding>I am a</ion-label>
<ion-select formControlName="role" mode="ios" okText="Okay" cancelText="Cancel">
<ion-select-option value="Admin">Admin</ion-select-option>
<ion-select-option value="Customer">Customer</ion-select-option>
</ion-select>
<ion-icon color="primary" name="arrow-down" mode="ios" slot="end"></ion-icon>
</ion-item>
Is there any other way of set custom icon or can anyone suggest a way tohow to remove select-icon-inner
You can override the content of the icon part. This worked for me, just go with:
ion-select::part(icon) {
content: url('your-icon-path/your-icon.svg');
}
👉 StackBlitz working example
In ionic v4 a workaround is hiding the icon through .scss file.
ion-select::part(icon) {
display: none !important;
}
ion-select::part(text) {
background-image: url(<ImageUrl>);
background-position: right;
background-repeat: no-repeat;
}
This worked for me in i5:
ion-select::part(icon) {
opacity: 1;
margin-left: 1em;
color: transparent;
background: url('assets/icons/light-mode/expand-down.svg') no-repeat center;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With