How to disable gray "wipe" effect when clicking mat-menu-item

I've got a mat-nav-list with mat-menu-items within. I've setup a routerLinkActive class in my scss to change the background and color of the text of the mat-menu-item when an item is clicked. However, when one of the items is clicked, it changes it background to a light gray and my background-color is only shown after you click elsewhere within the application.

The behavior is visible in the below gif.

I'd like for the mat-menu-item background-color to change to my chosen chosen color without the default "gray wipe" behavior, is this possible?

My code is below if required:

app.html

<mat-sidenav #sidenav mode="side" [opened]="(sideNavOpened)" class="sidenav-inner-content">
    <mat-nav-list>
        <a mat-list-item routerLink="/customers/search" routerLinkActive="active"><mat-icon>search</mat-icon> Search Customer</a>
        <a mat-list-item routerLink="/customers/create" routerLinkActive="active"><mat-icon>add</mat-icon> Create Customer</a>
    </mat-nav-list>
</mat-sidenav>

app.scss

.active {
    border-left: 5px solid mat-color($accent);
    background-color: mat-color($primary);
    color: $light-primary-text !important;
}

Just put !important after your background-color css to override mat's background color.

.active {
    border-left: 5px solid mat-color($accent);
    background-color: mat-color($primary) !important;
    color: $light-primary-text !important;
}

There are four methods to enable or disable Gray scale mode in windows 10. Method 1: Enable/Disable Gray scale mode using Group Policy Editor. Open Run command by pressing windows + R and type gpedit.msc and hit enter. Navigate to below mentioned path

The shadow is caused by 'mat-list-item-ripple' and 'mat-ripple'. I know of two solutions:

1) Add the following to your styles.css:

.mat-nav-list .mat-list-item .mat-list-item-ripple {
  visibility: hidden !important;
}

2) Or add the following to the .css of the page in question:

::ng-deep .mat-nav-list .mat-list-item .mat-list-item-ripple {
  visibility: hidden !important;
}

The Natural Way. First, start skipping use of color preserving shampoos as soon as possible to make color removal easier over time. A clarifying shampoo used regularly over a few weeks or months, depending on the texture and porosity of your strands, can lead to lifted color.

I'd advise against using !important wherever possible. With a view-encapsulated framework like Angular, it's almost never required to override CSS options. Plus, with overriding the ink effect's styles, the ripple and behavior is still there, just invisible--it's still a semi-expensive animation, both with resources and time taken to complete.

Instead, the MatList, MatOption, and MatNavList API has a native option called disableRipple to get rid of the ink effect.

<mat-sidenav #sidenav mode="side" [opened]="(sideNavOpened)" class="sidenav-inner-content">
    <mat-nav-list [disableRipple]="true">
        <a mat-list-item routerLink="/customers/search" routerLinkActive="active"><mat-icon>search</mat-icon> Search Customer</a>
        <a mat-list-item routerLink="/customers/create" routerLinkActive="active"><mat-icon>add</mat-icon> Create Customer</a>
    </mat-nav-list>
</mat-sidenav>

You can also use disableRipple selectively on each mat-list-item.

Begin spraying at one end or corner of the fence and spray individual fence pickets from top to bottom. Spray slowly to give the water enough time to strip the wood; it may take a few passes to

Going gray is a process, but realizing it's happening can feel very sudden. You may know immediately that you want to cover it with dye, or you may consider embracing the gray.

Remove the rags from inside the toilet bowl. Scrub the interior with a toilet brush or a stiff handheld brush. The bleach lightens and removes the discolorations. Flush the toilet to rinse.

1) Highlight, accessible from the Ribbon's Home tab. Select the text in question and apply "None." 2) Shading, accessible from the main menu bar's Format > Borders and Shading, which can be applied to selected text or to the whole paragraph. Cancel it by selecting "No Fill." 3) Cell fill.

Comments
  • From a quick look at the docs material.angular.io/components/menu/api there are three interesting @Input() that you might leverage to override the 'gray swipe' effect - have you tried defining backdropClass, hasBackdrop or panelClass?
  • Are you sure that this background-color: mat-color($primary); is correct? Try only background-color: $primary; if you have some color in primary variable. Also you can disable pointer events with pointer-events: none in CSS. If you can post link from this example on stackblitz please.
  • @N.Tasikj mat-color($primary) is correct. As you can see, it does update the color of my element, but it's not visible due to the mat-menu-item wipe being overlayed.
  • Aha yea, try it with making background-color !important, working for me
  • @N.Tasikj ah-ha, so simple, can't believe I missed that. Feel free to make an answer and I'll accept it.
  • Thanks for your answer, but this only applies to the animation effect, not the color overlay. The ripple effect is fine, but it was the color change that derailed my intended outcome.