Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change mat-select-arrow icon

Tags:

angular

How can I change the mat-select-arrow to another icon, besides the default dropdown?

I've tried various iterations of

.mat-select-arrow {
    icon: url('/assets/images/keyboard_arrow_down.png');
    content: icon;
}

Chrome developer tool's compute window does not seem to list any property that corresponds to the arrow type.

like image 436
Todd Fishburg Avatar asked Jul 20 '18 15:07

Todd Fishburg


People also ask

How do you remove mat select arrows?

to the component style's sheet or the styles. scss of your angular app. Caution this will remove every arrow in mat-select. if you want to remove arrow for a few ones just add a class to mat-form-field and nest your class in the scss file.


2 Answers

assume you are using this:

https://material.angular.io/components/select/overview

The Arrow here is made with pure css:

::ng-deep .mat-select-arrow {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid;
    margin: 0 4px;
}

to changes this, override the border values and set a background-image

Edit: add ::ng-deep; see comment from @Ruben Szekér

like image 184
enno.void Avatar answered Sep 17 '22 12:09

enno.void


I had the same issue, I solved by following this procedure.

  1. At first, I hide the mat-arrow by adding below this line of .css into component.css

    ::ng-deep .mat-select-arrow { opacity: 0; }

  2. And then, I have added the matIcon after the matselect but inside the MatFormField.

    <mat-icon matSuffix>domain</mat-icon>
    

or. You can add your custom Icon URL image by adding the border-images-source

Thanks

like image 33
Riyad Avatar answered Sep 17 '22 12:09

Riyad