how to define a dynamic size for mat-dialog Angular based on its content size

  angular, angular-material, mat-dialog

I am using angular mat-dialog. its content is varying from a single line to many paragraphs.
right now my dialog size is defined as :

const dialogRef = this.dialog.open(OrgDialogComponent, {
  width: '60%',
  height: '70%',
  data: this.org_result,
  panelClass: 'my-dialog2',
});

how can I resize it dynamically based on the content size. if the content is less then the mat-dialog size should shrink itself and if the content is long the window size gets up to a maximum of 60% width and 70% of the height.

enter image description here

Source: Angular Material Quesions

One Reply to “how to define a dynamic size for mat-dialog Angular based on its content size”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.