Skip to content

Setting dialog max-height does not work #8493

Open

Description

@swftvsn

Bug, feature request, or proposal:

Bug

What is the expected behavior?

To be able to change the max-height of the dialog

What is the current behavior?

It does not work.

What are the steps to reproduce?

http://plnkr.co/edit/X17ETao12PtHTKmpqV5s?p=preview
The dialog in question is configured to be

const settings: MatDialogConfig = {
  maxWidth: '99vw',
  maxHeight: '99vh'
}

But the height is the default one. It seems that the cdk-overlay-0 is correctly styled with style="max-width: 99vw; max-height: 99vh;" but the inner div.mat-dialog-content has max-height: 65vh; which dictates the height.

All the relevant code is in app.component.ts.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

All / latest

Is there anything else we should know?

Keep up the good work!

Activity

  1. RobertPaulson90 commented on Nov 21, 2017

    @RobertPaulson90

    Same issue :(

  2. added
    P3
    on Nov 28, 2017
  3. diogodomanski commented on Dec 13, 2017

    @diogodomanski

    Did you try to set height and/or width too?

    const settings: MatDialogConfig = {
      maxWidth: '99vw',
      maxHeight: '99vh',
    
      width: '99vw',
      height: '99vh'
    }
    
  4. wojtek1150 commented on Dec 18, 2017

    @wojtek1150

    Same issue

  5. RobertPaulson90 commented on Dec 19, 2017

    @RobertPaulson90

    My case was a user issue, what I wanted was minHeight

  6. added a commit that references this issue on Jan 4, 2018
    83da015
  7. added 2 commits that reference this issue on Jan 4, 2018
    8ee04db
    214f719
  8. added a commit that references this issue on Jan 12, 2018
    fb4dbf0
  9. added a commit that references this issue on Jan 21, 2018
    fd16286
  10. added a commit that references this issue on Jan 24, 2018
    67ab3e9
  11. mstawick commented on Feb 6, 2018

    @mstawick

    FYI, as a workaround I've applied maxHeight via panelClass class, and then it works as expected (as far as I can tell).

  12. added a commit that references this issue on Mar 2, 2018
    2a31c21
  13. 13 remaining items

  14. drorm commented on Feb 1, 2019

    @drorm

    Seems like doing something like the following works.

    .mat-dialog-content { max-height: 95%; }

  15. fuzolan commented on Feb 25, 2019

    @fuzolan

    Seems like doing something like the following works.

    .mat-dialog-content { max-height: 95%; }

    had no effect in my case. A simple fullscreen option would be nice. If you want to use mat-dialog-actions then you get another problems...

  16. added a commit that references this issue on Mar 1, 2019
    cc3ba6f
  17. added a commit that references this issue on Mar 30, 2019
    dccfb41
  18. jhuiet commented on May 9, 2019

    @jhuiet

    I know this isn't the 'best' practice, but I found a simple fix for me: an inline style addition!

    <mat-dialog-content style="max-height: 85vh">

    This was where I landed after needing scrolling on smaller screens (note the mat-dialog-content tag) and not wanting scrolling on larger screens...

  19. akvaliya commented on Oct 31, 2019

    @akvaliya

    Any progress on this issue? It's been long time. I am facing the same issue. maxHeight has no effect on dialog.

  20. joschne commented on Dec 11, 2019

    @joschne

    I think I found a relatively simple solution.

    See stackblitz example and my comments in dialog-content-example.ts.

  21. tsupryk commented on Jun 13, 2023

    @tsupryk

    Having same issue in latest Material v15 !!!

  22. LordMidi commented on Dec 3, 2024

    @LordMidi

    Having same issue in Material v18

  23. fredericojesus commented on Apr 29, 2025

    @fredericojesus

    This is still an issue, height, max-height and min-height do not work !!!
    @andrewseguin @mmalerba @crisbeto can you guys please take a look this ?

  24. arlowhite commented on Aug 27, 2025

    @arlowhite

    I'm on Angular 20.2.1, Material 20.2.0

    As mentioned above, the default max-height: 65vh on dialog-content is an issue (this is the element that flex grows), so first set that to max-height: none, or maybe more correct is to use calc and subtract your action bar and title bar heights:

    mat-dialog-content {
      // full viewport height minus action bar height
      max-height: calc(100vh - 74px);
    }

    Then set height and/or max-height on your dialog using MatDialog.open. Alternatively, if you want to set height from css, you can do this:

    ::ng-deep .mat-mdc-dialog-panel {
      max-height: 85vh;
    }
    
    @media (max-width: 600px) {
      ::ng-deep .mat-mdc-dialog-panel {
        // full height on mobile
        max-height: 100vh;
      }
    }

    Though use of ::ng-deep is discouraged https://angular.dev/guide/components/styling#ng-deep

    Also, if you have a <form> around your contents and actions bar, set that to display: contents;

  25. arlowhite commented on Aug 27, 2025

    @arlowhite

    IMO the change should be that if height is specified with dialog.open, then the dialog-content max-height: 65vh should be removed.

    Something like:

    .fixed-height .mat-mdc-dialog-content {
      max-height: none;
    }

    where fixed-height class is added to .mat-mdc-dialog-panel when you specify height (or max-height?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3area: material/dialog

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions