Angular - toolbar being hidden by drawer instead of sidenav












1















I am trying to create a dashboard-like interface where there is a persistent title toolbar at the top, and a collapsible sidenav on the left side. I have been trying a number of things here and there and this is as close as I have gotten:



HTML:



<mat-sidenav-container class="sidenav-container">
<mat-sidenav
#drawer
class="sidenav"
fixedInViewport="true"
[attr.role]="(isHandset$ | async) ? 'dialog' : 'navigation'"
[mode]="(isHandset$ | async) ? 'over' : 'side'"
[opened]="!(isHandset$ | async)">
<mat-toolbar color="primary"> <button
type="button"
aria-label="Toggle sidenav"
mat-icon-button
(click)="drawer.toggle()">
<mat-icon aria-label="Side nav toggle icon">menu</mat-icon>
</button>Menu</mat-toolbar>
<mat-nav-list>
<a mat-list-item [routerLink]="['/']">Home</a>
<a mat-list-item [routerLink]="['/locations']">Current Destinations</a>
<a mat-list-item [routerLink]="['/orders']">Today's Orders</a>
<a mat-list-item [routerLink]="['/logout']">Logout</a>
</mat-nav-list>
</mat-sidenav>
<mat-sidenav-content>
<mat-toolbar class="top-bar" color="primary">
<span>App Title</span>
</mat-toolbar>
<router-outlet></router-outlet>
</mat-sidenav-content>
</mat-sidenav-container>


CSS:



.sidenav-container {
height: 100%;
}

.sidenav {
display: flex;
width: 200px;
box-shadow: 3px 0 6px rgba(0,0,0,.24);
}
.top-bar {
position: fixed;
top: 0;
z-index:1000;
}


The problem is that the sidenav stays in place, and the top toolbar is what is getting hidden, along with the router-outlet content. It needs to be the other way around, but I can't seem to get it. This answer to another question is close, but in that instance the links on the left end up in a scroll bar that don't extend beyond the bottom of the toolbar at the top. Also, it appears to use an older version of Material Design or something. What am I missing?










share|improve this question























  • If you can provide a stackblitz link with your code will be useful to help you

    – Kalamarico
    Nov 13 '18 at 0:06











  • I created one, but nothing loads. I'm not sure why. Nonetheless, it has the code in it - not sure if it helps but here it is: stackblitz.com/edit/angular-ygytu8 Edit: Nevermind, I got it working - it should be ok now.

    – NellaGnute
    Nov 13 '18 at 1:33


















1















I am trying to create a dashboard-like interface where there is a persistent title toolbar at the top, and a collapsible sidenav on the left side. I have been trying a number of things here and there and this is as close as I have gotten:



HTML:



<mat-sidenav-container class="sidenav-container">
<mat-sidenav
#drawer
class="sidenav"
fixedInViewport="true"
[attr.role]="(isHandset$ | async) ? 'dialog' : 'navigation'"
[mode]="(isHandset$ | async) ? 'over' : 'side'"
[opened]="!(isHandset$ | async)">
<mat-toolbar color="primary"> <button
type="button"
aria-label="Toggle sidenav"
mat-icon-button
(click)="drawer.toggle()">
<mat-icon aria-label="Side nav toggle icon">menu</mat-icon>
</button>Menu</mat-toolbar>
<mat-nav-list>
<a mat-list-item [routerLink]="['/']">Home</a>
<a mat-list-item [routerLink]="['/locations']">Current Destinations</a>
<a mat-list-item [routerLink]="['/orders']">Today's Orders</a>
<a mat-list-item [routerLink]="['/logout']">Logout</a>
</mat-nav-list>
</mat-sidenav>
<mat-sidenav-content>
<mat-toolbar class="top-bar" color="primary">
<span>App Title</span>
</mat-toolbar>
<router-outlet></router-outlet>
</mat-sidenav-content>
</mat-sidenav-container>


CSS:



.sidenav-container {
height: 100%;
}

.sidenav {
display: flex;
width: 200px;
box-shadow: 3px 0 6px rgba(0,0,0,.24);
}
.top-bar {
position: fixed;
top: 0;
z-index:1000;
}


The problem is that the sidenav stays in place, and the top toolbar is what is getting hidden, along with the router-outlet content. It needs to be the other way around, but I can't seem to get it. This answer to another question is close, but in that instance the links on the left end up in a scroll bar that don't extend beyond the bottom of the toolbar at the top. Also, it appears to use an older version of Material Design or something. What am I missing?










share|improve this question























  • If you can provide a stackblitz link with your code will be useful to help you

    – Kalamarico
    Nov 13 '18 at 0:06











  • I created one, but nothing loads. I'm not sure why. Nonetheless, it has the code in it - not sure if it helps but here it is: stackblitz.com/edit/angular-ygytu8 Edit: Nevermind, I got it working - it should be ok now.

    – NellaGnute
    Nov 13 '18 at 1:33
















1












1








1








I am trying to create a dashboard-like interface where there is a persistent title toolbar at the top, and a collapsible sidenav on the left side. I have been trying a number of things here and there and this is as close as I have gotten:



HTML:



<mat-sidenav-container class="sidenav-container">
<mat-sidenav
#drawer
class="sidenav"
fixedInViewport="true"
[attr.role]="(isHandset$ | async) ? 'dialog' : 'navigation'"
[mode]="(isHandset$ | async) ? 'over' : 'side'"
[opened]="!(isHandset$ | async)">
<mat-toolbar color="primary"> <button
type="button"
aria-label="Toggle sidenav"
mat-icon-button
(click)="drawer.toggle()">
<mat-icon aria-label="Side nav toggle icon">menu</mat-icon>
</button>Menu</mat-toolbar>
<mat-nav-list>
<a mat-list-item [routerLink]="['/']">Home</a>
<a mat-list-item [routerLink]="['/locations']">Current Destinations</a>
<a mat-list-item [routerLink]="['/orders']">Today's Orders</a>
<a mat-list-item [routerLink]="['/logout']">Logout</a>
</mat-nav-list>
</mat-sidenav>
<mat-sidenav-content>
<mat-toolbar class="top-bar" color="primary">
<span>App Title</span>
</mat-toolbar>
<router-outlet></router-outlet>
</mat-sidenav-content>
</mat-sidenav-container>


CSS:



.sidenav-container {
height: 100%;
}

.sidenav {
display: flex;
width: 200px;
box-shadow: 3px 0 6px rgba(0,0,0,.24);
}
.top-bar {
position: fixed;
top: 0;
z-index:1000;
}


The problem is that the sidenav stays in place, and the top toolbar is what is getting hidden, along with the router-outlet content. It needs to be the other way around, but I can't seem to get it. This answer to another question is close, but in that instance the links on the left end up in a scroll bar that don't extend beyond the bottom of the toolbar at the top. Also, it appears to use an older version of Material Design or something. What am I missing?










share|improve this question














I am trying to create a dashboard-like interface where there is a persistent title toolbar at the top, and a collapsible sidenav on the left side. I have been trying a number of things here and there and this is as close as I have gotten:



HTML:



<mat-sidenav-container class="sidenav-container">
<mat-sidenav
#drawer
class="sidenav"
fixedInViewport="true"
[attr.role]="(isHandset$ | async) ? 'dialog' : 'navigation'"
[mode]="(isHandset$ | async) ? 'over' : 'side'"
[opened]="!(isHandset$ | async)">
<mat-toolbar color="primary"> <button
type="button"
aria-label="Toggle sidenav"
mat-icon-button
(click)="drawer.toggle()">
<mat-icon aria-label="Side nav toggle icon">menu</mat-icon>
</button>Menu</mat-toolbar>
<mat-nav-list>
<a mat-list-item [routerLink]="['/']">Home</a>
<a mat-list-item [routerLink]="['/locations']">Current Destinations</a>
<a mat-list-item [routerLink]="['/orders']">Today's Orders</a>
<a mat-list-item [routerLink]="['/logout']">Logout</a>
</mat-nav-list>
</mat-sidenav>
<mat-sidenav-content>
<mat-toolbar class="top-bar" color="primary">
<span>App Title</span>
</mat-toolbar>
<router-outlet></router-outlet>
</mat-sidenav-content>
</mat-sidenav-container>


CSS:



.sidenav-container {
height: 100%;
}

.sidenav {
display: flex;
width: 200px;
box-shadow: 3px 0 6px rgba(0,0,0,.24);
}
.top-bar {
position: fixed;
top: 0;
z-index:1000;
}


The problem is that the sidenav stays in place, and the top toolbar is what is getting hidden, along with the router-outlet content. It needs to be the other way around, but I can't seem to get it. This answer to another question is close, but in that instance the links on the left end up in a scroll bar that don't extend beyond the bottom of the toolbar at the top. Also, it appears to use an older version of Material Design or something. What am I missing?







css angular html5 layout angular-material2






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 12 '18 at 23:38









NellaGnuteNellaGnute

357




357













  • If you can provide a stackblitz link with your code will be useful to help you

    – Kalamarico
    Nov 13 '18 at 0:06











  • I created one, but nothing loads. I'm not sure why. Nonetheless, it has the code in it - not sure if it helps but here it is: stackblitz.com/edit/angular-ygytu8 Edit: Nevermind, I got it working - it should be ok now.

    – NellaGnute
    Nov 13 '18 at 1:33





















  • If you can provide a stackblitz link with your code will be useful to help you

    – Kalamarico
    Nov 13 '18 at 0:06











  • I created one, but nothing loads. I'm not sure why. Nonetheless, it has the code in it - not sure if it helps but here it is: stackblitz.com/edit/angular-ygytu8 Edit: Nevermind, I got it working - it should be ok now.

    – NellaGnute
    Nov 13 '18 at 1:33



















If you can provide a stackblitz link with your code will be useful to help you

– Kalamarico
Nov 13 '18 at 0:06





If you can provide a stackblitz link with your code will be useful to help you

– Kalamarico
Nov 13 '18 at 0:06













I created one, but nothing loads. I'm not sure why. Nonetheless, it has the code in it - not sure if it helps but here it is: stackblitz.com/edit/angular-ygytu8 Edit: Nevermind, I got it working - it should be ok now.

– NellaGnute
Nov 13 '18 at 1:33







I created one, but nothing loads. I'm not sure why. Nonetheless, it has the code in it - not sure if it helps but here it is: stackblitz.com/edit/angular-ygytu8 Edit: Nevermind, I got it working - it should be ok now.

– NellaGnute
Nov 13 '18 at 1:33














1 Answer
1






active

oldest

votes


















1














I finally solved this when I stumbled across a stackblitz example from the Material website. Here's the article:



Material - Creating a Responsive Layout for Mobile App Desktop



And here's the stackblitz example for it:



https://stackblitz.com/angular/pymganppqmm






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53271685%2fangular-toolbar-being-hidden-by-drawer-instead-of-sidenav%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    I finally solved this when I stumbled across a stackblitz example from the Material website. Here's the article:



    Material - Creating a Responsive Layout for Mobile App Desktop



    And here's the stackblitz example for it:



    https://stackblitz.com/angular/pymganppqmm






    share|improve this answer




























      1














      I finally solved this when I stumbled across a stackblitz example from the Material website. Here's the article:



      Material - Creating a Responsive Layout for Mobile App Desktop



      And here's the stackblitz example for it:



      https://stackblitz.com/angular/pymganppqmm






      share|improve this answer


























        1












        1








        1







        I finally solved this when I stumbled across a stackblitz example from the Material website. Here's the article:



        Material - Creating a Responsive Layout for Mobile App Desktop



        And here's the stackblitz example for it:



        https://stackblitz.com/angular/pymganppqmm






        share|improve this answer













        I finally solved this when I stumbled across a stackblitz example from the Material website. Here's the article:



        Material - Creating a Responsive Layout for Mobile App Desktop



        And here's the stackblitz example for it:



        https://stackblitz.com/angular/pymganppqmm







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 13 '18 at 3:26









        NellaGnuteNellaGnute

        357




        357






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53271685%2fangular-toolbar-being-hidden-by-drawer-instead-of-sidenav%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown