Angular2 Material Dialog Css, Dialog Size


Answer :

Content in md-dialog-content is automatically scrollable.

You can manually set the size in the call to MdDialog.open

let dialogRef = dialog.open(MyComponent, {   height: '400px',   width: '600px', }); 

Further documentation / examples for scrolling and sizing: https://material.angular.io/components/dialog/overview

Some colors should be determined by your theme. See here for theming docs: https://material.angular.io/guide/theming

If you want to override colors and such, use Elmer's technique of just adding the appropriate css.

Note that you must have the HTML 5 <!DOCTYPE html> on your page for the size of your dialog to fit the contents correctly ( https://github.com/angular/material2/issues/2351 )


There are two ways which we can use to change size of your MatDialog component in angular material

1) From Outside Component Which Call Dialog Component

import { MatDialog, MatDialogConfig, MatDialogRef } from '@angular/material';   dialogRef: MatDialogRef <any> ;  constructor(public dialog: MatDialog) { }  openDialog() {         this.dialogRef = this.dialog.open(TestTemplateComponent, {             height: '40%',             width: '60%'         });         this.dialogRef.afterClosed().subscribe(result => {             this.dialogRef = null;         });     } 

2) From Inside Dialog Component. dynamically change its size

import { MatDialog, MatDialogConfig, MatDialogRef } from '@angular/material';  constructor(public dialogRef: MatDialogRef<any>) { }   ngOnInit() {         this.dialogRef.updateSize('80%', '80%');     } 

use updateSize() in any function in dialog component. it will change dialog size automatically.

for more information check this link https://material.angular.io/components/component/dialog


With current version of Angular Material (6.4.7) you can use a custom class:

let dialogRef = dialog.open(UserProfileComponent, {   panelClass: 'my-class' }); 

Now put your class somewhere global (haven't been able to make this work elsewhere), e.g. in styles.css:

.my-class .mat-dialog-container{   height: 400px;   width: 600px;   border-radius: 10px;   background: lightcyan;   color: #039be5; } 

Done!


Comments

Popular posts from this blog

Chemistry - Bond Angles In NH3 And NCl3

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Can Feynman Diagrams Be Used To Represent Any Perturbation Theory?