Dynamic modal height based on content in Ionic v4

Original answer don’t count the header and footer height.
I fixed it with below scss. Remember to rename “ion-content” to “modal-content” when used.

ion-modal.auto-height {
  --height: auto;
  .modal-wrapper{
    width: 90vw;
    .ion-page {
      position: relative;
      contain: content;
      max-height: 90vh;
      .modal-content {
        overflow: auto;
      }
    }
  }
}
8 Likes