How to change angular material sort icon

Artur

I need to change default arrow icon from angular material matSort to a custom arrow.

The current code

 <mat-table #table [dataSource]="source" matSort (matSortChange)="sortData($event)" [matSortActive]="sort.active" [matSortDirection]="sort.direction">

Is there any way to do this ?

amuthan
::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;
      }
    }
  }
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to change state icon in Angular Material stepper?

change angular material datePicker icon

change the default icon in angular material

How to change size of mat-icon on Angular Material?

How to change state icon in Angular material stepper dynamically created component?

How do I change the color of an md-icon in Angular Material?

How to change angular material stepper step numbers to any icon or text?

Angular material stepper change icon color

How to change material-icon on click event with angular2/4 material?

How to change color icon of Nativeselect Material UI?

How to change mat-icon size in Material

How to change Material UI imported Icon on click

How to change icon in angular component

How to include material icon library in angular?

How to use <md-icon> in Angular Material?

How to add a clear icon on dropdown Angular Material?

How to set the color of an icon in Angular Material?

How to put icon in placeholder in Angular Material?

ANGULAR: How to change the * required in material?

Angular Material 2: mdStepper Header icon bg color change

It is possible change angular material mat-slide-toggle icon?

Remove or change the calendar icon from angular material datepicker

How to sort by date in Data table, Angular Material

How can I change an icon on hover in Angular?

How to change color of hamburger icon in material design navigation drawer

How to change the collapse/expand icon to right side of TreeView of material?

Material ui: How to change DatePicker text and calendar icon color?

How to change icon size on Alert in Material UI for React

How to change toolbar back button icon in android material components