How to change angular material sort icon
::ng-deep .mat-sort-header-arrow[style] {
// Hide default arrow stem
.mat-sort-header-stem {
display: none;
}
.mat-sort-header-indicator {
opacity: 1;
color: black;
font-weight: bold;
// Hide default arrow as its composed of left, right and middle
.mat-sort-header-pointer-left, .mat-sort-header-pointer-right, .mat-sort-header-pointer-middle {
display: none;
}
}
}
// My custom ascending arrow
[aria-sort="ascending"] {
::ng-deep .mat-sort-header-arrow {
.mat-sort-header-indicator {
&::before {
content: "\2191";
top: -1.6em;
position: absolute;
}
}
}
}
// My custom descending arrow
[aria-sort="descending"] {
::ng-deep .mat-sort-header-arrow {
.mat-sort-header-indicator {
&::before {
content: "\2193";
top: -2.4em;
position: absolute;
}
}
}
}
@Artur
You can try this
[aria-sort='ascending'] {
::ng-deep .mat-sort-header-arrow{
.mat-sort-header-indicator {
&::before{
font: normal normal normal 1.1rem/1 FontAwesome;
content: "\f0d7";
position: absolute;
top: .2rem;
}
}
}
}
[aria-sort='descending'] {
::ng-deep .mat-sort-header-arrow {
.mat-sort-header-indicator {
&::before{
font: normal normal normal 1.1rem/1 FontAwesome;
content: "\f0d8";
position: absolute;
top: -.9rem;
}
}
}
}
Try this.
app.component.ts
import {Component, ViewEncapsulation} from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
encapsulation: ViewEncapsulation.None
})
export class AppComponent {
title = 'app';
}
app.component.css
.mat-sort-header-stem {
height: 3px !important;
width: 10px !important;
transform: rotate(180deg) !important;
}
.mat-sort-header-pointer-left, .mat-sort-header-pointer-right {
width: 7px !important;
height: 3px !important;
}
.mat-sort-header-pointer-middle{
width: 0px !important;
height: 0px !important;
}