Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular Material 2 Scrolling Inside Mat Tab

I want to have a sidenav that has some buttons on top and tabs below that contain different data. I want to make the inside of the tabs scroll so that the buttons on top never go out of view, so that my users are not scrolling up when they want to use one of the buttons.

Here is an example: https://stackblitz.com/edit/angular-wdjfaa

As you can see in the example, when you open the drawer nothing scrolls. In the styles.scss I have added

.mat-drawer {
    overflow-y: unset!important;
}

So that the whole drawer doesn't scroll. The only way I have been able to get it to scroll is to set a fixed pixel heigh for the tab body, which I don't want to do because I need that to have a 100% height.

Anyone got any ideas?

Thanks!

like image 413
DevShadow Avatar asked Sep 18 '26 03:09

DevShadow


2 Answers

I just changed it to scroll and it appears to have worked:

.mat-drawer {
    overflow-y: scroll
}

Is this what you were trying to accomplish? https://stackblitz.com/edit/angular-wdjfaa-w7vurx

like image 161
Ambrown Avatar answered Sep 19 '26 19:09

Ambrown


Try using sticky property in css. Add the following class to you styles.scss

.mat-tab-header {
    z-index: 9999;
    position: sticky;
    top: 0px;
    background-color: white;
}
like image 39
Melchia Avatar answered Sep 19 '26 20:09

Melchia



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!