I have Open button
<button mat-raised-button (click)="openModal()
"type="button" color="primary">Open Modal </button>
On button button click, popup modal open and after close modal. cdk-focused
and cdk-program-focused
classes added and to this button and get some ripple effect on that.
I want to get rid of that style, want remove or overwrite those classes those added to button after close modal*
I suggest two solutions:
1. First, set an additional class on that button in order to avoid that all the mat-raised-buttons be affected by the style change, it's not your aim, I suppose.
HTML:
<button mat-raised-button class="myButton" (click)="openDialog();">Pick one</button>
CSS:
.myButton:focus{
box-shadow: 0 0 rgba(255, 255, 255, 1) !important;
transition:none !important;
background-color: rgba(255, 255, 255, 1) !important;
-webkit-tap-highlight-color:rgba(255, 255, 255, 1) !important;
}
Then you can set the style of mat-raised-button either by
a) setting it in component's stylesheet with ::ng-deep:
::ng-deep .myButton>.mat-button-focus-overlay {
background-color:transparent !important;
}
::ng-deep .mat-app-background{
background: white !important
}
Demo
b) setting with ViewEncapsulation.none:
Class:
import { ViewEncapsulation } from '@angular/core';
...
@Component({
...
encapsulation:ViewEncapsulation.None
})
CSS:
.myButton>.mat-button-focus-overlay {
background-color:transparent !important;
}
.myButton>.mat-app-background{
background: white !important
}
Demo
c) setting it in style.css:
.myButton>.mat-button-focus-overlay {
background-color:transparent !important;
}
.myButton>.mat-app-background{
background: white !important
}
Demo
...
<input matInput #input [(ngModel)]="name" placeholder="What's your name?">
...
<button mat-raised-button class="myButton" (click)=" input.focus();openDialog() ">Pick one </button>
Demo
.mat-button-focus-overlay {
background-color:transparent !important;
}
.mat-app-background{
background: transparent !important
}
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