Desperately trying to find a selector for md-dialog-container in angular 2's material design with no success.
I can make changes in f12 of chrome with no problem, but carrying out those changes with a valid selector in css is a problem. Researched /deep/ but it is now deprecated.
I have tried md-dialog-container {}
, md-dialog-container.md-dialog-container{}
, and md-dialog-container.md-dialog-container[role="dialog"]
with no success.
Attached are images of me making these changes in f12 of chrome with no problem.
You can override the default dialog container styles by adding a css class in your global styles.css. For example: .custom-dialog-container .mat-dialog-container { /* add your styles */ } After that, you'll need to providies you css class as a panelClass parameter to your dialog: Read this official documentation for more information.
W3.CSS is the perfect stylesheet for designing applications with a "Material Design" look: The Cinque Terre (five lands) is a portion of the Italian Riviera.
Material Design was designed by Google in 2014 and has later been adopted in many Google applications. Material Design uses elements that remind us of paper and ink. In addition the elements have realistic shadows and hover effects. W3.CSS is the perfect stylesheet for designing applications with a "Material Design" look:
Use a simple dialog when displaying two actions. You have the option to use an alert when displaying two actions. When there are three or more actions with long text labels in a Material dialog, products may use iOS action sheets or bottom sheets. Stack actions if a text label is long.
Here's what worked for me:
encapsulation: ViewEncapsulation.None
this.dialogRef = this.dialog.open(myDialogComponent, { panelClass: 'my-dialog' });
.my-dialog { .mat-dialog-container { padding: 0; } }
The issue you're running into is due to ViewEncapsulation. By default, Angular2 uses an emulated Shadow DOM which prevents styles from components affecting each other. You can opt out of ViewEncapsulation (not recommended) or you could use the /deep/ selector. According to Angular documentation in the link provided it is alright to use this selector using Angular's default emulated Shadow DOM.
From my understanding, Angular has its own CSS processor that should should make it alright for you to use these selectors for right now. I assume they're translated. If using these is truly not an option for you, you'll have to switch to ViewEncapsulation.None
.
import {ViewEncapsulation} from '@angular/core'; // and any other imports
@Component({
selector: 'my-selector',
templateUrl: './my-selector.component.html',
styleUrls: ['./my-selector.component.scss'],
encapsulation: ViewEncapsulation.None
})
For Angular and Material >6.x, I was able to use the ::ng-deep selector:
::ng-deep .mat-dialog-container {
padding: 16px;
}
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